INNER CODE UNIT · Python

lifespan

yaojingang/GEORank · backend/app/main.py:201

async def lifespan(app: FastAPI):
    """应用生命周期 — 数据库迁移完成后初始化默认配置。"""
    settings.validate_production_security()

    from app.core.database import async_session
    async with async_session() as db:
        try:
            await _seed_settings(db)
            await _seed_default_homepage_release(db)
        except Exception as e:
            print(f"[startup] settings init skipped: {e}")

    yield
    # 关闭时清理资源
    await engine.dispose()


app = FastAPI(

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…