Log server start/stop (#3715)

This commit is contained in:
Stanislav Novosad
2025-10-14 20:05:35 -06:00
committed by GitHub
parent d4aa212f20
commit ef3167cb07

View File

@@ -1,6 +1,7 @@
import uuid import uuid
from contextlib import asynccontextmanager
from datetime import datetime from datetime import datetime
from typing import Awaitable, Callable from typing import Any, AsyncGenerator, Awaitable, Callable
import structlog import structlog
from fastapi import FastAPI, Response, status from fastapi import FastAPI, Response, status
@@ -50,12 +51,20 @@ def custom_openapi() -> dict:
return app.openapi_schema return app.openapi_schema
@asynccontextmanager
async def lifespan(_: FastAPI) -> AsyncGenerator[None, Any]:
"""Lifespan context manager for FastAPI app startup and shutdown."""
LOG.info("Server started")
yield
LOG.info("Server shutting down")
def get_agent_app() -> FastAPI: def get_agent_app() -> FastAPI:
""" """
Start the agent server. Start the agent server.
""" """
app = FastAPI() app = FastAPI(lifespan=lifespan)
# Add CORS middleware # Add CORS middleware
app.add_middleware( app.add_middleware(