Skip to content

Commit e3e6bcd

Browse files
NubeDevclaude
andcommitted
fix(fly): don't crash-loop the machine on a failed migration
A failing migration aborted the entrypoint under `set -e`. Fly restarts on exit, so the machine looped until it hit max-restart-count and the app never served at all — and the restart loop was fast enough to make `fly ssh console` fail its handshake, blocking diagnosis of the very migration that caused it. Migrations run in a transaction, so a failure rolls back and leaves the schema at the last good version. Serving on that schema degrades whatever feature needed the new columns but keeps the rest of the site up, which beats a total outage. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent 4d90347 commit e3e6bcd

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

scripts/fly-entrypoint.sh

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,18 @@ case "$cmd" in
8787

8888
echo "[entrypoint] running migrations"
8989
cd /app
90-
/usr/local/bin/dev-pulse migrate --config "$RUNTIME"
90+
# A failed migration must not crash-loop the machine. `set -e` would
91+
# abort boot here, and because Fly restarts on exit the app then never
92+
# serves at all — one bad migration takes the whole site down and
93+
# blocks even SSH access to diagnose it. Migrations run in a
94+
# transaction, so a failure rolls back and leaves the schema at the
95+
# last good version; serving on that older schema degrades whatever
96+
# feature needed the new columns, but keeps everything else up.
97+
if ! /usr/local/bin/dev-pulse migrate --config "$RUNTIME"; then
98+
echo "[entrypoint] WARNING: migrations FAILED — starting anyway on the" >&2
99+
echo "[entrypoint] last-good schema. Features needing the new schema" >&2
100+
echo "[entrypoint] will misbehave until this is fixed." >&2
101+
fi
91102

92103
echo "[entrypoint] starting Caddy on :8080"
93104
caddy run --config /etc/caddy/Caddyfile --adapter caddyfile &

0 commit comments

Comments
 (0)