updates again
This commit is contained in:
+26
-3
@@ -132,6 +132,7 @@ class HealthResponse(BaseModel):
|
||||
version: str
|
||||
uptime: str
|
||||
database_status: str
|
||||
radarr_database: Optional[Dict[str, Any]] = None
|
||||
|
||||
# ---------------------------
|
||||
# Core Processing
|
||||
@@ -769,8 +770,10 @@ async def radarr_webhook(request: Request, background_tasks: BackgroundTasks):
|
||||
|
||||
@app.get("/health")
|
||||
async def health() -> HealthResponse:
|
||||
"""Health check endpoint"""
|
||||
"""Health check endpoint with Radarr database status"""
|
||||
uptime = datetime.now(timezone.utc) - start_time
|
||||
|
||||
# Check NFOGuard database
|
||||
try:
|
||||
with db.get_connection() as conn:
|
||||
conn.execute("SELECT 1").fetchone()
|
||||
@@ -778,11 +781,31 @@ async def health() -> HealthResponse:
|
||||
except Exception as e:
|
||||
db_status = f"error: {e}"
|
||||
|
||||
# Check Radarr database if available
|
||||
radarr_db_health = None
|
||||
overall_status = "healthy" if db_status == "healthy" else "degraded"
|
||||
|
||||
# Get Radarr client with database access
|
||||
radarr_client = client_manager.get_radarr_client()
|
||||
if radarr_client and hasattr(radarr_client, 'db_client') and radarr_client.db_client:
|
||||
try:
|
||||
radarr_db_health = radarr_client.db_client.health_check()
|
||||
if radarr_db_health["status"] != "healthy":
|
||||
overall_status = "degraded"
|
||||
except Exception as e:
|
||||
radarr_db_health = {
|
||||
"status": "error",
|
||||
"error": str(e),
|
||||
"tested_at": datetime.now(timezone.utc).isoformat(timespec="seconds")
|
||||
}
|
||||
overall_status = "degraded"
|
||||
|
||||
return HealthResponse(
|
||||
status="healthy" if db_status == "healthy" else "degraded",
|
||||
status=overall_status,
|
||||
version=version,
|
||||
uptime=str(uptime),
|
||||
database_status=db_status
|
||||
database_status=db_status,
|
||||
radarr_database=radarr_db_health
|
||||
)
|
||||
|
||||
@app.get("/stats")
|
||||
|
||||
Reference in New Issue
Block a user