khlevon's picture
feat: setup blaxel agentic server and add ops scripts
76faade
raw
history blame contribute delete
771 Bytes
from contextlib import asynccontextmanager
from fastapi import FastAPI
from opentelemetry.instrumentation.fastapi import FastAPIInstrumentor
from src.agents.server.error import init_error_handlers
from src.agents.server.middleware import init_middleware
from src.agents.server.router import router
from src.common.config import settings
from src.common.logger import get_logger
logger = get_logger(__name__)
@asynccontextmanager
async def lifespan(app: FastAPI):
logger.info(f"Server running on port {settings.BL_SERVER_PORT}")
yield
logger.info("Server shutting down")
app = FastAPI(lifespan=lifespan)
init_error_handlers(app)
init_middleware(app)
app.include_router(router)
FastAPIInstrumentor.instrument_app(app, exclude_spans=["receive", "send"])