-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathruntime_paths.py
More file actions
51 lines (29 loc) · 950 Bytes
/
Copy pathruntime_paths.py
File metadata and controls
51 lines (29 loc) · 950 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
from __future__ import annotations
import os
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parent
def runtime_root() -> Path:
raw = os.environ.get("WEBAGENT_RUNTIME_ROOT")
if raw:
return Path(raw).resolve()
return REPO_ROOT
def env_dir() -> Path:
return runtime_root() / "env"
def state_path() -> Path:
return env_dir() / "state.json"
def db_path() -> Path:
return runtime_root() / "data.db"
def sites_dir() -> Path:
return runtime_root() / "sites"
def tasks_dir() -> Path:
return runtime_root() / "tasks"
def database_dir() -> Path:
return runtime_root() / "database"
def server_port() -> int:
raw = os.environ.get("WEBAGENT_SERVER_PORT", "8014").strip()
try:
return int(raw)
except Exception:
return 8014
def server_base_url() -> str:
return os.environ.get("WEBAGENT_SERVER_BASE_URL", f"http://localhost:{server_port()}").rstrip("/")