fix: retry production health checks during startup

This commit is contained in:
syntaxbullet
2026-07-13 12:33:09 +02:00
parent 0e41c890f9
commit 64049baef0
2 changed files with 32 additions and 4 deletions

View File

@@ -14,6 +14,10 @@ PUBLIC_URL="${PUBLIC_URL:-https://$APP_DOMAIN}"
DEPLOY_CADDY="${DEPLOY_CADDY:-0}"
RUN_MIGRATIONS="${RUN_MIGRATIONS:-0}"
SKIP_VERIFY="${SKIP_VERIFY:-0}"
VERIFY_RETRIES="${VERIFY_RETRIES:-30}"
VERIFY_RETRY_DELAY_SECONDS="${VERIFY_RETRY_DELAY_SECONDS:-2}"
VERIFY_RETRY_MAX_SECONDS="${VERIFY_RETRY_MAX_SECONDS:-60}"
VERIFY_REQUEST_TIMEOUT_SECONDS="${VERIFY_REQUEST_TIMEOUT_SECONDS:-20}"
SSH_TARGET="$SSH_USER@$VPS_HOST"
COMPOSE_FILE="$APP_ROOT/current/deploy/vps/docker-compose.yml"
@@ -86,10 +90,22 @@ ssh -t -i "$SSH_KEY" -p "$VPS_PORT" "$SSH_TARGET" "
sudo docker ps --format 'table {{.Names}}\t{{.Image}}\t{{.Status}}\t{{.Ports}}'
"
verify_url() {
local url="$1"
echo "Verifying $url"
curl -fsSIL \
--retry "$VERIFY_RETRIES" \
--retry-all-errors \
--retry-delay "$VERIFY_RETRY_DELAY_SECONDS" \
--retry-max-time "$VERIFY_RETRY_MAX_SECONDS" \
--max-time "$VERIFY_REQUEST_TIMEOUT_SECONDS" \
"$url" | sed -n '1,12p'
}
if [[ "$SKIP_VERIFY" != "1" ]]; then
echo "Verifying $PUBLIC_URL"
curl -fsSIL --max-time 20 "$PUBLIC_URL/" | sed -n '1,12p'
curl -fsSIL --max-time 20 "$PUBLIC_URL/admin" | sed -n '1,12p'
verify_url "$PUBLIC_URL/"
verify_url "$PUBLIC_URL/admin"
fi
echo "Deploy complete: $REVISION"