Make auto-login optional at startup so backend always boots

This commit is contained in:
Thigazhezhilan J 2026-05-02 15:38:36 +05:30
parent 1b3be0437d
commit 6027dd3c6f

View File

@ -8,7 +8,14 @@ from fastapi.middleware.cors import CORSMiddleware
from app.admin_role_service import bootstrap_super_admin
from app.admin_router import router as admin_router
from app.routers.auth import router as auth_router
from app.routers.auto_login import router as auto_login_router
try:
from app.routers.auto_login import router as auto_login_router
from app.services.auto_login_service import start_auto_login_scheduler
_auto_login_available = True
except Exception as _auto_login_err:
auto_login_router = None
_auto_login_available = False
print(f"[STARTUP] auto-login unavailable: {_auto_login_err}", flush=True)
from app.routers.broker import router as broker_router
from app.routers.health import router as health_router
from app.routers.paper import router as paper_router
@ -18,7 +25,6 @@ from app.routers.support_ticket import router as support_ticket_router
from app.routers.system import router as system_router
from app.routers.zerodha import router as zerodha_router, public_router as zerodha_public_router
from app.services.db import _db_config as _validate_db_config
from app.services.auto_login_service import start_auto_login_scheduler
from app.services.live_equity_service import start_live_equity_snapshot_daemon
from app.services.strategy_service import init_log_state, resume_running_runs
from market import router as market_router
@ -141,11 +147,12 @@ def _run_startup_tasks(app: FastAPI):
app.state.background_warnings["live_equity_snapshot_daemon"] = str(exc)
print(f"[STARTUP] live equity snapshot daemon failed to start: {exc}", flush=True)
try:
start_auto_login_scheduler()
except Exception as exc:
app.state.background_warnings["auto_login_scheduler"] = str(exc)
print(f"[STARTUP] auto-login scheduler failed to start: {exc}", flush=True)
if _auto_login_available:
try:
start_auto_login_scheduler()
except Exception as exc:
app.state.background_warnings["auto_login_scheduler"] = str(exc)
print(f"[STARTUP] auto-login scheduler failed to start: {exc}", flush=True)
@asynccontextmanager
@ -168,7 +175,8 @@ def create_app() -> FastAPI:
allow_headers=["*"],
)
app.include_router(auto_login_router)
if auto_login_router is not None:
app.include_router(auto_login_router)
app.include_router(strategy_router)
app.include_router(auth_router)
app.include_router(broker_router)