INNER CODE UNIT · Python
lifespan
flukelaster/ai-trading-agent · backend/app/main.py:105
async def lifespan(app: FastAPI):
from app.logging_config import configure_logging
configure_logging()
logger.info("Starting Trading Bot (multi-symbol)...")
from app.auth import _assert_auth_consistent
_assert_auth_consistent()
# Phase 1 observability: slow query logger — attach once, survives entire app lifetime
install_slow_query_logger(db_engine, threshold_ms=settings.db_slow_query_threshold_ms)
# Auto-add missing columns/tables (safe for production — IF NOT EXISTS guards)
# Each statement runs in its own session to isolate transaction abort on error.
from sqlalchemy import text