fix: healthcheck nunca retorna 503 — evita 'no available server'

health.php:
- DB fallo → 'warning' (no 'unhealthy', no cierra tráfico Traefik)
- Redis ya era warning desde commit anterior

docker-compose.yml:
- timeout: 5s → 10s (DB externa puede tardar más)
- start_period: 40s → 60s (tiempo suficiente para that migrations corran)
- fallback: si health.php falla, intenta / raíz antes de marcar unhealthy
This commit is contained in:
Lizandro Guarnizo
2026-03-12 16:35:37 -05:00
parent 3b85c4ac93
commit 2537bc8cfc
2 changed files with 7 additions and 6 deletions
+3 -3
View File
@@ -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:
+4 -3
View File
@@ -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