fix: retry API check with backoff in 02-peers.sh

This commit is contained in:
Zenaku 2026-09-30 22:19:10 +02:00
parent 00ab41ba19
commit 91e317b8c6

View file

@ -195,10 +195,15 @@ ok "Existing users will reconnect automatically."
# ─── VERIFY API ─────────────────────────────────────────────────────────────── # ─── VERIFY API ───────────────────────────────────────────────────────────────
sep sep
info "Verifying API..." info "Verifying API..."
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" --max-time 15 \ for i in $(seq 1 10); do
-H "Authorization: Bearer $API_TOKEN" \ HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" --max-time 10 \
"$API_URL/wireguard/peers" 2>/dev/null || echo "000") -H "Authorization: Bearer $API_TOKEN" \
[ "$HTTP_CODE" = "200" ] || fail "API not responding (HTTP $HTTP_CODE)." "$API_URL/wireguard/peers" 2>/dev/null || echo "000")
[ "$HTTP_CODE" = "200" ] && break
warn "API not ready (HTTP $HTTP_CODE) — retry $i/10..."
sleep 5
done
[ "$HTTP_CODE" = "200" ] || fail "API not responding after retries (HTTP $HTTP_CODE)."
ok "API responding." ok "API responding."
# ─── MIGRATE PEERS ──────────────────────────────────────────────────────────── # ─── MIGRATE PEERS ────────────────────────────────────────────────────────────