Improved database connection and logging

This commit is contained in:
florian committed 2025-10-12 15:31:15 +02:00
1 parent 448c89c247
commit c7c14b6713
2 files changed
+63 -20

No files matched your search

+4 -1
View File
@@ -5,7 +5,7 @@ from starlette.exceptions import HTTPException as StarletteHTTPException
from typing import Dict
from pydantic import BaseModel
from validator import verify_api_key
from db import get_db, create_connection_pool, close_connection_pool
from db import get_db, create_connection_pool, close_connection_pool, start_healthcheck_thread
from logger_handler import setup_logger
from rabbitmq_handler import send_message_to_rmq, create_connection, close_connection
import uvicorn
@@ -33,6 +33,9 @@ async def lifespan(app: FastAPI):
logger.info("Connecting to RabbitMQ...")
app.state.rmq_connection = create_connection()
start_healthcheck_thread()
logger.info("MySQL healthcheck thread started.")
yield
logger.info("Closing RabbitMQ connection...")
close_connection(app.state.rmq_connection)