Lots of changes to support Alembic and external DB
This commit is contained in:
@@ -69,7 +69,29 @@ async def root():
|
||||
|
||||
@app.get("/health")
|
||||
async def health_check():
|
||||
return {"status": "healthy", "timestamp": "2024-01-01T00:00:00Z"}
|
||||
"""Health check endpoint with database connectivity verification"""
|
||||
from datetime import datetime
|
||||
from sqlalchemy import text
|
||||
from app.db.session import SessionLocal
|
||||
|
||||
health_status = {
|
||||
"status": "healthy",
|
||||
"timestamp": datetime.utcnow().isoformat() + "Z",
|
||||
"version": "2.0.0"
|
||||
}
|
||||
|
||||
# Check database connectivity
|
||||
try:
|
||||
db = SessionLocal()
|
||||
db.execute(text("SELECT 1"))
|
||||
db.close()
|
||||
health_status["database"] = "connected"
|
||||
except Exception as e:
|
||||
health_status["status"] = "unhealthy"
|
||||
health_status["database"] = "disconnected"
|
||||
health_status["error"] = str(e)
|
||||
|
||||
return health_status
|
||||
|
||||
# Include API router
|
||||
app.include_router(api_router, prefix=settings.api_v1_str)
|
||||
|
||||
Reference in New Issue
Block a user