diff --git a/nfoguard.py b/nfoguard.py index a1c4368..6460712 100644 --- a/nfoguard.py +++ b/nfoguard.py @@ -785,20 +785,25 @@ async def health() -> HealthResponse: 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" + # Get Radarr client with database access from movie processor + try: + if hasattr(movie_processor, 'radarr') and movie_processor.radarr: + radarr_client = movie_processor.radarr + if 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" + except Exception as e: + # If movie processor isn't available, skip database health check + _log("DEBUG", f"Skipping Radarr database health check: {e}") return HealthResponse( status=overall_status,