INNER CODE UNIT · Python
lifespan
SPThole/CoexistAI · app.py:163
async def lifespan(app_instance):
# Startup
print("\n" + "="*80, flush=True)
print("FastAPI app starting up...", flush=True)
logger.info("FastAPI app starting up...")
app_state['status'] = 'starting'
app_state['message'] = 'Initializing components...'
try:
init_components()
print("="*80 + "\n", flush=True)
except Exception as e:
print(f"STARTUP ERROR: {e}", flush=True)
print("="*80 + "\n", flush=True)
logger.error(f"Failed to initialize components during startup: {e}", exc_info=True)
app_state['status'] = 'error'
app_state['message'] = f'Startup failed: {e}'
yield
# Shutdown