mirror of
https://github.com/Xe138/AI-Trader.git
synced 2026-04-02 01:27:24 -04:00
Add database initialization at module load time to ensure it runs regardless of how uvicorn handles the lifespan context manager. Issue: The lifespan function wasn't being triggered consistently when uvicorn loads the app module, causing "no such table: jobs" errors. Solution: Initialize database when the module is imported (after app creation), providing a reliable fallback that works in all deployment scenarios. This provides defense-in-depth: 1. Lifespan function (ideal path) 2. Module-level initialization (fallback/guarantee) Both paths check deployment mode and call the appropriate init function.