Pre-launch — Gluecron is in final validation. Public signups and git hosting for non-owner users open after launch review.
Commit141561funknown_key

perf(deploy): skip bun install + bun build when unchanged + faster healthz poll

perf(deploy): skip bun install + bun build when unchanged + faster healthz poll

Three skip-on-failure optimisations to the self-deploy script. Each
falls back to current behaviour if the check produces no answer, so
nothing is silently bypassed.

1. SKIP BUN INSTALL when bun.lockb (or bun.lock) hash matches the
   last successful install. Stores the hash in .next/bun-install.stamp.
   Saves ~2-5s on the 90%+ of deploys that don't touch dependencies.
   First-time install + any dep change run normally.

2. SKIP BUN BUILD --compile when no src/*.ts(x) file changed since
   the last successful compile. Same .next/build-src.stamp pattern.
   Saves ~5-15s on docs-only / ROADMAP-only / config-only commits.
   If the compiled binary is missing, builds anyway.

3. FASTER HEALTHZ POLL: 10× 500ms then 10× 2s. Most deploys are
   green within ~1s of systemctl restart returning, so the old fixed
   2s loop wasted 1-3s. Same ~30s outer ceiling.

Expected combined effect on the common warm-deploy case: 25s → 12-18s.
Cold (lockfile changed): unchanged. Bigger wins (collapse 11+ SSH
sessions in GHA, pre-build in CI, socket activation for zero downtime)
are tracked in ROADMAP for a separate pass.
Claude committed on May 24, 2026Parent: 609a27a
1 file changed+6110141561fbc8f2da8e80b0ad12bd608917088c5892
1 changed file+61−10
Modifiedscripts/self-deploy.sh+61−10View fileUnifiedSplit
125125DEPLOY_FAILED=0
126126FAIL_REASON=""
127127
128# ── 4. bun install --frozen-lockfile ───────────────────────────────────────
128# ── 4. bun install --frozen-lockfile (skipped if lockfile unchanged) ──────
129# Track the last-installed lockfile hash in a stamp file. If it matches the
130# current lockfile we skip — saves ~2-5s every deploy that doesn't touch
131# dependencies (90%+ of deploys). On any error the fallback runs install
132# anyway so we never silently skip a needed install.
133STAMP_DIR="${GLUECRON_DEPLOY_STAMP_DIR:-.next}"
134mkdir -p "$STAMP_DIR" 2>/dev/null || true
135LOCK_STAMP="$STAMP_DIR/bun-install.stamp"
136LOCK_HASH=""
137if [ -f bun.lockb ]; then
138 LOCK_HASH=$(sha256sum bun.lockb 2>/dev/null | awk '{print $1}' || echo "")
139elif [ -f bun.lock ]; then
140 LOCK_HASH=$(sha256sum bun.lock 2>/dev/null | awk '{print $1}' || echo "")
141fi
142LAST_HASH=""
143if [ -f "$LOCK_STAMP" ]; then
144 LAST_HASH=$(cat "$LOCK_STAMP" 2>/dev/null || echo "")
145fi
146
129147BI_START=$(date +%s)
130148notify_step "bun-install" "in_progress"
131if "$BUN" install --frozen-lockfile >>"$LOG" 2>&1; then
149if [ -n "$LOCK_HASH" ] && [ "$LOCK_HASH" = "$LAST_HASH" ] && [ -d node_modules ]; then
150 log " v bun install skipped (lockfile unchanged: ${LOCK_HASH:0:12})"
151 notify_step "bun-install" "succeeded" "$(( ( $(date +%s) - BI_START ) * 1000 ))"
152elif "$BUN" install --frozen-lockfile >>"$LOG" 2>&1; then
153 echo "$LOCK_HASH" > "$LOCK_STAMP" 2>/dev/null || true
132154 log " v bun install ok"
133155 notify_step "bun-install" "succeeded" "$(( ( $(date +%s) - BI_START ) * 1000 ))"
134156else
153175 fi
154176fi
155177
156# ── 6. Build the static binary ─────────────────────────────────────────────
178# ── 6. Build the static binary (skipped if no source files changed) ──────
179# We hash every tracked src/*.ts(x) file and stash the digest in a stamp
180# file. If nothing in src/ changed, the binary from the previous deploy
181# is still valid — saves 5-15s on docs-only / config-only commits.
182# On any error the fallback rebuilds anyway.
157183if [ "$DEPLOY_FAILED" = "0" ]; then
158184 BD_START=$(date +%s)
159185 notify_step "build" "in_progress"
160186 mkdir -p .next
161187 COMPILED=.next/gluecron-server
162188 COMPILED_TMP=.next/gluecron-server.new
163 if "$BUN" build --compile --outfile "$COMPILED_TMP" src/index.ts >>"$LOG" 2>&1; then
189 BUILD_STAMP="$STAMP_DIR/build-src.stamp"
190 SRC_HASH=$(find src -type f \( -name "*.ts" -o -name "*.tsx" \) -print0 2>/dev/null \
191 | sort -z \
192 | xargs -0 sha256sum 2>/dev/null \
193 | sha256sum 2>/dev/null \
194 | awk '{print $1}' || echo "")
195 LAST_BUILD_HASH=""
196 if [ -f "$BUILD_STAMP" ]; then
197 LAST_BUILD_HASH=$(cat "$BUILD_STAMP" 2>/dev/null || echo "")
198 fi
199
200 if [ -n "$SRC_HASH" ] && [ "$SRC_HASH" = "$LAST_BUILD_HASH" ] && [ -x "$COMPILED" ]; then
201 log " v build skipped (src/ unchanged: ${SRC_HASH:0:12})"
202 notify_step "build" "succeeded" "$(( ( $(date +%s) - BD_START ) * 1000 ))"
203 elif "$BUN" build --compile --outfile "$COMPILED_TMP" src/index.ts >>"$LOG" 2>&1; then
164204 mv -f "$COMPILED_TMP" "$COMPILED"
165205 chmod +x "$COMPILED"
206 echo "$SRC_HASH" > "$BUILD_STAMP" 2>/dev/null || true
166207 log " v compiled $COMPILED"
167208 notify_step "build" "succeeded" "$(( ( $(date +%s) - BD_START ) * 1000 ))"
168209 else
204245 fi
205246fi
206247
207# ── 8. Wait for /healthz to be green (up to 30s) ──────────────────────────
248# ── 8. Wait for /healthz to be green (fast poll, up to ~30s) ─────────────
249# Tighter polling: 500ms × 10 (covers the common case where the service
250# is healthy within 1-2s of restart returning), then 2s × 10 for the slow
251# path. Cuts a typical successful deploy by 1-3s vs the old fixed 2s poll.
208252if [ "$DEPLOY_FAILED" = "0" ]; then
209253 HZ_START=$(date +%s)
210254 notify_step "healthz" "in_progress"
211255 green=0
212 for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15; do
213 code=$(curl -s -o /dev/null -w "%{http_code}" "$HEALTHZ_URL" || echo "000")
214 log " healthz attempt $i: $code"
215 if [ "$code" = "200" ]; then green=1; break; fi
216 sleep 2
256 for i in 1 2 3 4 5 6 7 8 9 10; do
257 code=$(curl -s -o /dev/null -w "%{http_code}" --max-time 2 "$HEALTHZ_URL" || echo "000")
258 if [ "$code" = "200" ]; then green=1; log " healthz fast attempt $i: $code (green)"; break; fi
259 sleep 0.5
217260 done
261 if [ "$green" = "0" ]; then
262 for i in 11 12 13 14 15 16 17 18 19 20; do
263 code=$(curl -s -o /dev/null -w "%{http_code}" --max-time 2 "$HEALTHZ_URL" || echo "000")
264 log " healthz slow attempt $i: $code"
265 if [ "$code" = "200" ]; then green=1; break; fi
266 sleep 2
267 done
268 fi
218269 if [ "$green" = "1" ]; then
219270 log " v /healthz green"
220271 notify_step "healthz" "succeeded" "$(( ( $(date +%s) - HZ_START ) * 1000 ))"
221272