File size: 709 Bytes
38e0dee |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
import os
from contextlib import asynccontextmanager
from logging import getLogger
from fastapi import FastAPI
from opentelemetry.instrumentation.fastapi import FastAPIInstrumentor
from .server.error import init_error_handlers
from .server.middleware import init_middleware
from .server.router import router
logger = getLogger(__name__)
@asynccontextmanager
async def lifespan(app: FastAPI):
logger.info(f"Server running on port {os.getenv('BL_SERVER_PORT', 80)}")
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"])
|