consolidated env vars and .env

This commit is contained in:
ben
2026-04-02 17:14:05 -04:00
parent 90b9dad59c
commit 1757318523
5 changed files with 57 additions and 39 deletions

View File

@@ -20,9 +20,8 @@ load_project_dotenv()
REPO_ROOT = Path(__file__).resolve().parent
DEFAULT_BACKEND_HOST = os.getenv("YOUDIS_BACKEND_HOST", "127.0.0.1")
DEFAULT_BACKEND_PORT = int(os.getenv("YOUDIS_BACKEND_PORT", "8000"))
RUN_BACKEND = os.getenv("YOUDIS_RUN_BACKEND", "1") not in {"0", "false", "False"}
RUN_DISCORD = os.getenv("YOUDIS_RUN_DISCORD", "1") not in {"0", "false", "False"}
ENABLED_ADAPTERS = os.getenv("YOUDIS_ENABLED_ADAPTERS", "discord")
ENABLE_BACKEND = os.getenv("YOUDIS_RUN_BACKEND", "1") not in {"0", "false", "False"}
ENABLE_DISCORD = os.getenv("ENABLE_DISCORD", "1") not in {"0", "false", "False"}
BACKEND_HEALTH_TIMEOUT = float(os.getenv("YOUDIS_BACKEND_HEALTH_TIMEOUT", "20"))
BACKEND_HEALTH_INTERVAL = float(os.getenv("YOUDIS_BACKEND_HEALTH_INTERVAL", "0.5"))
@@ -76,14 +75,9 @@ ADAPTER_STARTERS = {
def selected_adapters() -> list[str]:
requested = [name.strip() for name in ENABLED_ADAPTERS.split(",") if name.strip()]
if not RUN_DISCORD:
requested = [name for name in requested if name != "discord"]
unknown = [name for name in requested if name not in ADAPTER_STARTERS]
if unknown:
raise ValueError(f"unknown adapters requested: {', '.join(sorted(unknown))}")
requested: list[str] = []
if ENABLE_DISCORD:
requested.append("discord")
return requested
@@ -122,12 +116,12 @@ async def run() -> int:
env = build_child_env()
adapters = selected_adapters()
if not RUN_BACKEND and not adapters:
if not ENABLE_BACKEND and not adapters:
print("nothing to start: backend is disabled and no adapters are enabled")
return 1
try:
if RUN_BACKEND:
if ENABLE_BACKEND:
backend = await start_backend(env)
managed.append(backend)
print(f"started backend on {backend_url()}")