Make auto-login optional at startup so backend always boots
This commit is contained in:
parent
1b3be0437d
commit
6027dd3c6f
@ -8,7 +8,14 @@ from fastapi.middleware.cors import CORSMiddleware
|
|||||||
from app.admin_role_service import bootstrap_super_admin
|
from app.admin_role_service import bootstrap_super_admin
|
||||||
from app.admin_router import router as admin_router
|
from app.admin_router import router as admin_router
|
||||||
from app.routers.auth import router as auth_router
|
from app.routers.auth import router as auth_router
|
||||||
|
try:
|
||||||
from app.routers.auto_login import router as auto_login_router
|
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.broker import router as broker_router
|
||||||
from app.routers.health import router as health_router
|
from app.routers.health import router as health_router
|
||||||
from app.routers.paper import router as paper_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.system import router as system_router
|
||||||
from app.routers.zerodha import router as zerodha_router, public_router as zerodha_public_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.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.live_equity_service import start_live_equity_snapshot_daemon
|
||||||
from app.services.strategy_service import init_log_state, resume_running_runs
|
from app.services.strategy_service import init_log_state, resume_running_runs
|
||||||
from market import router as market_router
|
from market import router as market_router
|
||||||
@ -141,6 +147,7 @@ def _run_startup_tasks(app: FastAPI):
|
|||||||
app.state.background_warnings["live_equity_snapshot_daemon"] = str(exc)
|
app.state.background_warnings["live_equity_snapshot_daemon"] = str(exc)
|
||||||
print(f"[STARTUP] live equity snapshot daemon failed to start: {exc}", flush=True)
|
print(f"[STARTUP] live equity snapshot daemon failed to start: {exc}", flush=True)
|
||||||
|
|
||||||
|
if _auto_login_available:
|
||||||
try:
|
try:
|
||||||
start_auto_login_scheduler()
|
start_auto_login_scheduler()
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
@ -168,6 +175,7 @@ def create_app() -> FastAPI:
|
|||||||
allow_headers=["*"],
|
allow_headers=["*"],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if auto_login_router is not None:
|
||||||
app.include_router(auto_login_router)
|
app.include_router(auto_login_router)
|
||||||
app.include_router(strategy_router)
|
app.include_router(strategy_router)
|
||||||
app.include_router(auth_router)
|
app.include_router(auth_router)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user