INNER CODE UNIT · Python

lifespan

Kohei-Wada/taskdog · packages/taskdog-server/src/taskdog_server/api/app.py:48

    async def lifespan(app: FastAPI) -> AsyncIterator[None]:
        """FastAPI lifespan context manager.

        Initializes logging, API context, and connection manager on startup.
        Stores all state in app.state for proper scoping.
        """
        # Startup: Configure logging first
        configure_logging()

        # Apply a pending restore (if any) BEFORE the engine is created, so the
        # restored DB is what Alembic then migrates forward. A failed swap must
        # not leave the server permanently unstartable: log and continue with
        # the existing DB, leaving the pending file for a later retry.
        try:
            SqliteBackupStore(resolve_database_url(config)).apply_pending_restore()
        except OSError:
            logging.getLogger(__name__).exception(
                "Failed to apply pending database restore; "

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…