diff --git a/scripts/run_standalone.py b/scripts/run_standalone.py index d36f08a2..974904bc 100755 --- a/scripts/run_standalone.py +++ b/scripts/run_standalone.py @@ -109,21 +109,27 @@ def log_stream(stream, prefix, color): def start_backend(backend_port: int, backend_cfg: Dict[str, Any], background: bool = False): logger.info(f"Starting Backend on port {backend_port}...") - + app_cfg = backend_cfg.get("application", {}) env = os.environ.copy() env["DATA_DIR"] = app_cfg.get("data_dir", "./data") env["LOGS_DIR"] = app_cfg.get("logs_dir", "./logs") env["LOG_LEVEL"] = backend_cfg.get("logging", {}).get("log_level", "INFO") - + # Ensure directories exist os.makedirs(env["DATA_DIR"], exist_ok=True) os.makedirs(env["LOGS_DIR"], exist_ok=True) - + + # Use venv python if available + python_exe = sys.executable + venv_python = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "venv", "bin", "python3") + if os.path.exists(venv_python): + python_exe = venv_python + cmd = [ - sys.executable, "-m", "uvicorn", - "backend.main:app", - "--host", "0.0.0.0", + python_exe, "-m", "uvicorn", + "backend.main:app", + "--host", "0.0.0.0", "--port", str(backend_port) ]