diff --git a/src/cli/modules/server_config.py b/src/cli/modules/server_config.py index 62dec8d..f577912 100644 --- a/src/cli/modules/server_config.py +++ b/src/cli/modules/server_config.py @@ -4,6 +4,7 @@ This module handles all configuration file operations without any CLI/presentation logic. """ import json +import os from pathlib import Path from typing import Optional, Dict, Any, List @@ -16,11 +17,16 @@ def __init__(self, config_file: Optional[Path] = None): Initialize ServerConfig with a config file path. Args: - config_file: Path to the config file. If None, defaults to openarc_config.json in project root. + config_file: Path to the config file. If None, OPENARC_CONFIG_FILE env var when set, + otherwise defaults to openarc_config.json in project root. """ if config_file is None: - project_root = Path(__file__).parent.parent.parent.parent - config_file = project_root / "openarc_config.json" + env_path = os.environ.get("OPENARC_CONFIG_FILE") + if env_path: + config_file = Path(env_path) + else: + project_root = Path(__file__).parent.parent.parent.parent + config_file = project_root / "openarc_config.json" self.config_file = Path(config_file) diff --git a/src/server/main.py b/src/server/main.py index 64ce2e6..66f6a9f 100644 --- a/src/server/main.py +++ b/src/server/main.py @@ -54,7 +54,8 @@ async def lifespan(app: FastAPI): if models: from pathlib import Path - config_file = Path(__file__).parent.parent.parent / "openarc_config.json" + env_config = os.environ.get("OPENARC_CONFIG_FILE") + config_file = Path(env_config) if env_config else Path(__file__).parent.parent.parent / "openarc_config.json" if config_file.exists(): with open(config_file) as f: config = json.load(f)