diff --git a/docker-compose.yml b/docker-compose.yml index ff4f35e..455fd29 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -33,11 +33,11 @@ services: networks: - whatsapp-network healthcheck: - test: ["CMD", "curl", "-f", "http://localhost/health.php"] + test: ["CMD-SHELL", "curl -sf http://localhost/health.php || curl -sf http://localhost/ || exit 1"] interval: 30s - timeout: 5s + timeout: 10s retries: 3 - start_period: 40s + start_period: 60s logging: driver: "json-file" options: diff --git a/health.php b/health.php index ea8ff76..80fa823 100644 --- a/health.php +++ b/health.php @@ -30,15 +30,16 @@ try { $result = $db->query("SELECT 1")->fetch(); $health['checks']['database'] = [ - 'status' => $result ? 'ok' : 'error', + 'status' => $result ? 'ok' : 'warning', 'host' => DB_HOST ]; } catch (Exception $e) { + // DB caída = warning, no unhealthy — Traefik debe seguir ruteando + // (mejor mostrar error 500 en la app que "no available server") $health['checks']['database'] = [ - 'status' => 'error', + 'status' => 'warning', 'error' => $e->getMessage() ]; - $health['status'] = 'unhealthy'; } // 3. Check Redis