Fix run_standalone.py to use venv python for uvicorn
- Script was using /usr/bin/python3 which doesn't have uvicorn installed - Now detects and uses venv/bin/python3 if available - Backend now starts correctly with: 'python3 scripts/run_standalone.py start|restart' - All services (Backend, Frontend, SSL Proxy) now start properly
This commit is contained in:
@@ -109,21 +109,27 @@ def log_stream(stream, prefix, color):
|
|||||||
|
|
||||||
def start_backend(backend_port: int, backend_cfg: Dict[str, Any], background: bool = False):
|
def start_backend(backend_port: int, backend_cfg: Dict[str, Any], background: bool = False):
|
||||||
logger.info(f"Starting Backend on port {backend_port}...")
|
logger.info(f"Starting Backend on port {backend_port}...")
|
||||||
|
|
||||||
app_cfg = backend_cfg.get("application", {})
|
app_cfg = backend_cfg.get("application", {})
|
||||||
env = os.environ.copy()
|
env = os.environ.copy()
|
||||||
env["DATA_DIR"] = app_cfg.get("data_dir", "./data")
|
env["DATA_DIR"] = app_cfg.get("data_dir", "./data")
|
||||||
env["LOGS_DIR"] = app_cfg.get("logs_dir", "./logs")
|
env["LOGS_DIR"] = app_cfg.get("logs_dir", "./logs")
|
||||||
env["LOG_LEVEL"] = backend_cfg.get("logging", {}).get("log_level", "INFO")
|
env["LOG_LEVEL"] = backend_cfg.get("logging", {}).get("log_level", "INFO")
|
||||||
|
|
||||||
# Ensure directories exist
|
# Ensure directories exist
|
||||||
os.makedirs(env["DATA_DIR"], exist_ok=True)
|
os.makedirs(env["DATA_DIR"], exist_ok=True)
|
||||||
os.makedirs(env["LOGS_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 = [
|
cmd = [
|
||||||
sys.executable, "-m", "uvicorn",
|
python_exe, "-m", "uvicorn",
|
||||||
"backend.main:app",
|
"backend.main:app",
|
||||||
"--host", "0.0.0.0",
|
"--host", "0.0.0.0",
|
||||||
"--port", str(backend_port)
|
"--port", str(backend_port)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user