fix(devops): harden staging deploy health check race #142

Merged
integrator-bot merged 1 commits from fix/141-staging-healthcheck-retry into main 2026-02-28 18:40:44 +01:00

View File

@@ -66,7 +66,31 @@ chown -R wpp:wpp "${APP_DIR}"
runuser -u wpp -- test -w "${APP_DIR}"
systemctl restart wpp-staging.service
curl -fsS http://127.0.0.1:8000/healthz
HEALTH_URL="http://127.0.0.1:8000/healthz"
MAX_ATTEMPTS=7
SLEEP_SECONDS=1
ATTEMPT=1
until curl -fsS "${HEALTH_URL}" >/dev/null; do
if [ "${ATTEMPT}" -ge "${MAX_ATTEMPTS}" ]; then
echo "[deploy] ERROR: health check failed after ${MAX_ATTEMPTS} attempts: ${HEALTH_URL}" >&2
echo "[deploy] service status (wpp-staging.service):" >&2
systemctl --no-pager --full status wpp-staging.service >&2 || true
echo "[deploy] recent service logs (wpp-staging.service):" >&2
journalctl --no-pager -u wpp-staging.service -n 80 >&2 || true
exit 1
fi
echo "[deploy] health check not ready (attempt ${ATTEMPT}/${MAX_ATTEMPTS}); retrying in ${SLEEP_SECONDS}s"
sleep "${SLEEP_SECONDS}"
ATTEMPT=$((ATTEMPT + 1))
if [ "${SLEEP_SECONDS}" -lt 8 ]; then
SLEEP_SECONDS=$((SLEEP_SECONDS * 2))
fi
done
echo "[deploy] health check passed: ${HEALTH_URL}"
REMOTE
echo "[deploy] OK: staging deploy complete for CT ${CT_ID} (${REF_NAME})"