Changes committed
This commit is contained in:
39
docengine/app/events/handlers.py
Normal file
39
docengine/app/events/handlers.py
Normal file
@@ -0,0 +1,39 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from app.core.logging_config import get_logger, setup_logging
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
||||
|
||||
def on_startup() -> None:
|
||||
"""Application startup event handler."""
|
||||
setup_logging()
|
||||
logger.info("application_starting", event="startup")
|
||||
|
||||
# Ensure storage directories exist
|
||||
from app.storage.provider import get_storage_provider
|
||||
try:
|
||||
get_storage_provider()
|
||||
logger.info("storage_initialized")
|
||||
except Exception as e:
|
||||
logger.error("storage_init_failed", error=str(e))
|
||||
|
||||
# Verify database connection
|
||||
from app.core.database import check_database_connection
|
||||
if check_database_connection():
|
||||
logger.info("database_connected")
|
||||
else:
|
||||
logger.error("database_connection_failed")
|
||||
|
||||
logger.info("application_started", event="startup_complete")
|
||||
|
||||
|
||||
def on_shutdown() -> None:
|
||||
"""Application shutdown event handler."""
|
||||
logger.info("application_shutting_down", event="shutdown")
|
||||
|
||||
# Cleanup resources
|
||||
from app.core.database import engine
|
||||
engine.dispose()
|
||||
|
||||
logger.info("application_stopped", event="shutdown_complete")
|
||||
Reference in New Issue
Block a user