This commit is contained in:
2025-10-23 19:41:24 +02:00
parent c81a493fb1
commit ffb182e3ba
7 changed files with 180 additions and 643 deletions

View File

@@ -91,13 +91,19 @@ def get_series_app() -> Optional[SeriesApp]:
@app.on_event("startup")
async def startup_event():
async def startup_event() -> None:
"""Initialize application on startup."""
try:
# Initialize SeriesApp with configured directory and store it on
# application state so it can be injected via dependencies.
if settings.anime_directory:
app.state.series_app = SeriesApp(settings.anime_directory)
else:
# Log warning when anime directory is not configured
print(
"WARNING: ANIME_DIRECTORY not configured. "
"Some features may be unavailable."
)
# Initialize progress service with websocket callback
progress_service = get_progress_service()
@@ -105,7 +111,7 @@ async def startup_event():
async def broadcast_callback(
message_type: str, data: dict, room: str
):
) -> None:
"""Broadcast progress updates via WebSocket."""
message = {
"type": message_type,
@@ -118,6 +124,7 @@ async def startup_event():
print("FastAPI application started successfully")
except Exception as e:
print(f"Error during startup: {e}")
raise # Re-raise to prevent app from starting in broken state
@app.on_event("shutdown")