fix(deploy): wait for exact candidate health version

This commit is contained in:
2026-09-09 11:28:53 -03:00
parent d938db7913
commit ad7ec2ca2b
+8 -2
View File
@@ -247,16 +247,22 @@ echo "========== HEALTH =========="
HEALTH_OK=0 HEALTH_OK=0
for _ in $(seq 1 60); do for _ in $(seq 1 60); do
if curl -fsS --max-time 5 http://127.0.0.1:3101/api/v3/health > "$BACKUP/health.json" 2>/dev/null; then if curl -fsS --max-time 5 http://127.0.0.1:3101/api/v3/health > "$BACKUP/health.json" 2>/dev/null; then
if grep -F '"status":"ok"' "$BACKUP/health.json" >/dev/null; then if grep -Fq '"status":"ok"' "$BACKUP/health.json" \
&& grep -Fq "\"version\":\"$EXPECTED_API_VERSION\"" "$BACKUP/health.json" \
&& grep -Fq '"database":"ok"' "$BACKUP/health.json"; then
HEALTH_OK=1 HEALTH_OK=1
break break
fi fi
CURRENT_API_VERSION="$(node -e 'try { const h = JSON.parse(require("fs").readFileSync(process.argv[1], "utf8")); process.stdout.write(String(h.version || "unknown")); } catch { process.stdout.write("invalid"); }' "$BACKUP/health.json")"
echo "API respondió pero aún no es la candidata (actual=$CURRENT_API_VERSION, esperada=$EXPECTED_API_VERSION). Reintentando..."
fi fi
sleep 2 sleep 2
done done
if [ "$HEALTH_OK" -ne 1 ]; then if [ "$HEALTH_OK" -ne 1 ]; then
echo "ERROR: API no pasó healthcheck." echo "ERROR: API candidata no pasó healthcheck/version/database dentro del plazo."
[ ! -f "$BACKUP/health.json" ] || cat "$BACKUP/health.json"
docker compose logs --tail=180 api docker compose logs --tail=180 api
false false
fi fi