mirror of
https://github.com/fromchat-messenger/web.git
synced 2026-09-22 19:15:08 +03:00
Fix duplicated logging
This commit is contained in:
+25
-1
@@ -1,10 +1,34 @@
|
||||
from fastapi import FastAPI
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
import logging
|
||||
from contextlib import asynccontextmanager
|
||||
from migration import run_migrations
|
||||
|
||||
from routes import account, messaging, profile, push
|
||||
|
||||
# Configure logging
|
||||
logger = logging.getLogger("uvicorn.error")
|
||||
logger.handlers.clear()
|
||||
|
||||
@asynccontextmanager
|
||||
async def lifespan(app: FastAPI):
|
||||
"""Handle application lifespan events."""
|
||||
# Startup
|
||||
try:
|
||||
logger.info("Starting database migration check...")
|
||||
run_migrations()
|
||||
logger.info("Database migrations completed successfully.")
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to run database migrations: {e}")
|
||||
raise
|
||||
|
||||
yield
|
||||
|
||||
# Shutdown (if needed in the future)
|
||||
# logger.info("Application shutdown")
|
||||
|
||||
# Инициализация FastAPI
|
||||
app = FastAPI(title="PixelChat")
|
||||
app = FastAPI(title="FromChat", lifespan=lifespan)
|
||||
|
||||
# CORS
|
||||
app.add_middleware(
|
||||
|
||||
Reference in New Issue
Block a user