From 60242f30b8d1c07cfd764eb7b0eb48db9d20ed34 Mon Sep 17 00:00:00 2001 From: JSONbored <49853598+JSONbored@users.noreply.github.com> Date: Sat, 11 Jul 2026 06:58:45 -0700 Subject: [PATCH] fix(selfhost): retry the /ready probe in selfhost-post-update-check.sh instead of a single attempt (#5085) docker compose up -d returns as soon as the container starts, well before the app inside has finished booting and bound its port, so a single immediate curl reliably false-failed on a completely normal deploy -- hit twice today. The gittensory service's own Docker healthcheck already documents and tolerates this (start_period: 60s, "tolerates the Postgres cold start"); the post-update script had no equivalent tolerance. Retries up to 90s by default (configurable via SELFHOST_READY_RETRIES/SELFHOST_READY_RETRY_DELAY_SECONDS), verified against a local mock server that fails twice before succeeding, and against one that never succeeds (exhausts and exits non-zero). --- scripts/selfhost-post-update-check.sh | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/scripts/selfhost-post-update-check.sh b/scripts/selfhost-post-update-check.sh index 42759d8d35..cd85d386cf 100755 --- a/scripts/selfhost-post-update-check.sh +++ b/scripts/selfhost-post-update-check.sh @@ -30,9 +30,24 @@ if [ -z "$container_id" ]; then exit 1 fi +# Retry, don't single-probe: `docker compose up -d` returns as soon as the container STARTS, well before +# the app inside has bound its port -- a single immediate curl reliably false-fails on a normal boot. Budget +# matches the gittensory service's own Docker healthcheck start_period (60s, docker-compose.yml) plus margin, +# polling often enough that a normal ~15-20s boot returns almost immediately once actually ready. +READY_RETRIES="${SELFHOST_READY_RETRIES:-45}" +READY_RETRY_DELAY_SECONDS="${SELFHOST_READY_RETRY_DELAY_SECONDS:-2}" + echo "selfhost post-update check: probing $READY_URL" -if ! curl -sf "$READY_URL" >/dev/null; then - echo "error: $READY_URL did not return HTTP 2xx" >&2 +ready=0 +for _ in $(seq 1 "$READY_RETRIES"); do + if curl -sf "$READY_URL" >/dev/null; then + ready=1 + break + fi + sleep "$READY_RETRY_DELAY_SECONDS" +done +if [ "$ready" -ne 1 ]; then + echo "error: $READY_URL did not return HTTP 2xx after $READY_RETRIES attempts ($((READY_RETRIES * READY_RETRY_DELAY_SECONDS))s)" >&2 exit 1 fi