Enhance gluetun PIA WireGuard rotator with improved rate limit handling and retry logic. Update README to document new RATE_LIMIT_WAIT_SECONDS variable for managing retries after PIA rate limits.
Build and Push Docker Images / build-and-push (push) Successful in 49s

This commit is contained in:
2026-08-03 21:31:10 +02:00
parent 9436182c0c
commit d5791a4ac5
3 changed files with 58 additions and 8 deletions
@@ -28,13 +28,40 @@ sleep_until_next_rotate() {
sleep "$wait_s"
}
# Matches rotate.sh EXIT_RATE_LIMITED (EX_TEMPFAIL)
readonly EXIT_RATE_LIMITED=75
run_rotation() {
local reason="$1"
local wait_s="${RATE_LIMIT_WAIT_SECONDS:-3600}"
local rc
while true; do
log "$reason"
rc=0
/usr/local/bin/rotate.sh || rc=$?
case "$rc" in
0)
return 0
;;
"$EXIT_RATE_LIMITED")
log "PIA rate-limited (too many attempts); waiting ${wait_s}s before retry"
sleep "$wait_s"
reason="Retrying rotation after rate-limit wait"
;;
*)
>&2 echo "Rotation failed with exit code $rc"
return "$rc"
;;
esac
done
}
log "Starting gluetun PIA WireGuard rotator (TZ=${TZ:-UTC}, ROTATE_AT=${ROTATE_AT:-03:00})"
log "Running rotation on startup"
/usr/local/bin/rotate.sh
run_rotation "Running rotation on startup"
while true; do
sleep_until_next_rotate
log "Running scheduled daily rotation"
/usr/local/bin/rotate.sh
run_rotation "Running scheduled daily rotation"
done