some fixes

This commit is contained in:
2025-12-02 13:24:22 +01:00
parent ae77a11782
commit e0a7c6baa9
6 changed files with 52 additions and 29 deletions

View File

@@ -51,6 +51,15 @@ async def lifespan(app: FastAPI):
try:
logger.info("Starting FastAPI application...")
# Initialize database first (required for migration and other services)
try:
from src.server.database.connection import init_db
await init_db()
logger.info("Database initialized successfully")
except Exception as e:
logger.error("Failed to initialize database: %s", e, exc_info=True)
raise # Database is required, fail startup if it fails
# Load configuration from config.json and sync with settings
try:
from src.server.services.config_service import get_config_service
@@ -128,6 +137,14 @@ async def lifespan(app: FastAPI):
except Exception as e:
logger.error("Error stopping download service: %s", e, exc_info=True)
# Close database connections
try:
from src.server.database.connection import close_db
await close_db()
logger.info("Database connections closed")
except Exception as e:
logger.error("Error closing database: %s", e, exc_info=True)
logger.info("FastAPI application shutdown complete")