Fix new services implementation 9

This commit is contained in:
Urtzi Alfaro
2025-08-16 08:00:52 +02:00
parent 055ce10c66
commit 9de0f9943c
5 changed files with 37 additions and 83 deletions

View File

@@ -15,6 +15,8 @@ from contextlib import asynccontextmanager
from .core.config import settings
from .core.database import db_manager
from .api import recipes, production, ingredients
# Import models to register them with SQLAlchemy metadata
from .models import recipes as recipe_models
# Configure logging
@@ -33,7 +35,7 @@ async def lifespan(app: FastAPI):
# Create database tables
try:
db_manager.create_all_tables()
await db_manager.create_tables()
logger.info("Database tables created successfully")
except Exception as e:
logger.error(f"Failed to create database tables: {e}")
@@ -97,17 +99,14 @@ async def health_check():
"""Health check endpoint"""
try:
# Test database connection
db = db_manager.get_session()
try:
db.execute("SELECT 1")
finally:
db.close()
health_result = await db_manager.health_check()
return {
"status": "healthy",
"service": settings.SERVICE_NAME,
"version": settings.SERVICE_VERSION,
"environment": settings.ENVIRONMENT
"environment": settings.ENVIRONMENT,
"database": health_result
}
except Exception as e:
logger.error(f"Health check failed: {e}")