Skip to content

Commit 0800f23

Browse files
authored
fix(selfhost): retry the /ready probe in selfhost-post-update-check.sh instead of a single attempt (#5085) (#5086)
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).
1 parent f22516c commit 0800f23

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

scripts/selfhost-post-update-check.sh

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,24 @@ if [ -z "$container_id" ]; then
3030
exit 1
3131
fi
3232

33+
# Retry, don't single-probe: `docker compose up -d` returns as soon as the container STARTS, well before
34+
# the app inside has bound its port -- a single immediate curl reliably false-fails on a normal boot. Budget
35+
# matches the gittensory service's own Docker healthcheck start_period (60s, docker-compose.yml) plus margin,
36+
# polling often enough that a normal ~15-20s boot returns almost immediately once actually ready.
37+
READY_RETRIES="${SELFHOST_READY_RETRIES:-45}"
38+
READY_RETRY_DELAY_SECONDS="${SELFHOST_READY_RETRY_DELAY_SECONDS:-2}"
39+
3340
echo "selfhost post-update check: probing $READY_URL"
34-
if ! curl -sf "$READY_URL" >/dev/null; then
35-
echo "error: $READY_URL did not return HTTP 2xx" >&2
41+
ready=0
42+
for _ in $(seq 1 "$READY_RETRIES"); do
43+
if curl -sf "$READY_URL" >/dev/null; then
44+
ready=1
45+
break
46+
fi
47+
sleep "$READY_RETRY_DELAY_SECONDS"
48+
done
49+
if [ "$ready" -ne 1 ]; then
50+
echo "error: $READY_URL did not return HTTP 2xx after $READY_RETRIES attempts ($((READY_RETRIES * READY_RETRY_DELAY_SECONDS))s)" >&2
3651
exit 1
3752
fi
3853

0 commit comments

Comments
 (0)