INNER CODE UNIT · Python

lifespan

yezz123/ai-template · backend/src/dogeapi/main.py:32

async def lifespan(app: FastAPI) -> AsyncIterator[None]:
    """App lifespan: build per-app Redis client + AuthX, run feature setup."""
    settings: Settings = app.state.settings

    redis = Redis.from_url(settings.REDIS_URL, decode_responses=False)
    app.state.redis = redis
    app.state.authx = build_authx(settings, redis=redis)

    if settings.FEATURE_LOGFIRE and settings.LOGFIRE_TOKEN:
        try:
            from dogeapi.observability import setup_logfire

            setup_logfire(app, settings)
        except ImportError:
            pass

    try:
        yield

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…