mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-04 07:38:43 +01:00
`/opt/<app>/app` is a symlink into `releases/`, and `find` does not descend a logical symlink path. The generated launch.sh resolved its own directory with plain `pwd`, so the `server.js` search returned nothing and the app crash-looped with "no server.js found and START_CMD unset". This has now cost two outages. vitareba hit it on its first release-deploy (2026-07-17) and the fix went into deploy.sh, which sed-patched the *already generated* file on every deploy. That repaired the output and left the generator emitting the broken version — so the bug was still fully present, just masked by whichever ran last. sbb-fundbuero hit the identical failure on 2026-09-08 the moment sync-infra.sh ran without a deploy behind it. Fixing the output of a generator does not fix the generator. - `scripts/hetzner/launch.sh.tmpl` is now the single definition, with `pwd -P`. - `sync-infra.sh` renders it (`__PORT__` substituted per app) instead of carrying its own heredoc copy. - `deploy.sh` no longer sed-patches launch.sh. One writer. - `test-launch-template.sh` builds the real releases layout — a release dir plus an `app` symlink into it, plus a decoy `server.js` under node_modules — and asserts the template's own discovery resolves the right file through the symlink. It carries a negative control that fails the suite if plain `pwd` ever starts passing, so the test cannot quietly stop testing anything. Proved by mutation on a copy: reverting `pwd -P` to `pwd` makes the suite exit 1 with the exact production error. Wired into `test:ops`, so `pnpm run verify` covers it. All 15 apps on the box currently have the correct `pwd -P` (deploy.sh's sed had been keeping them alive), so removing the patch changes nothing about the running fleet. Claude-Session: https://claude.ai/code/session_01NfPenJdSXVtN8SQ9wHG4Hp Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
23 lines
1.4 KiB
Cheetah
23 lines
1.4 KiB
Cheetah
#!/usr/bin/env bash
|
|
# Generated onto the box by sync-infra.sh. __PORT__ is substituted per app.
|
|
# This template is the ONE definition of the launch script — do not paste a
|
|
# second copy into deploy.sh or patch the generated file after the fact.
|
|
set -euo pipefail
|
|
# `pwd -P`, not `pwd`: /opt/<name>/app is a SYMLINK into releases/, and find(1)
|
|
# does not descend a logical symlink path. With a plain `pwd` the server.js
|
|
# search below returns nothing and the app crash-loops on every deploy.
|
|
#
|
|
# This has now cost two outages. vitareba hit it on its first release-deploy
|
|
# (2026-07-17) and the fix was applied to deploy.sh — which sed-patched the
|
|
# already-generated file — instead of to the generator that keeps emitting the
|
|
# broken version. sbb-fundbuero hit the identical failure on 2026-09-08 the
|
|
# moment sync-infra.sh ran without a subsequent deploy. Fixing the output of a
|
|
# generator does not fix the generator.
|
|
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
|
|
if [ -f "$HERE/.env" ]; then set -a; source "$HERE/.env"; set +a; fi
|
|
export NODE_ENV=production PORT=__PORT__ HOSTNAME=127.0.0.1
|
|
SERVER_JS=$(find "$HERE" -maxdepth 4 -name server.js -not -path "*node_modules*" | head -1)
|
|
if [ -n "$SERVER_JS" ]; then exec /usr/bin/node "$SERVER_JS"; fi
|
|
# Non-Next services define their own entrypoint via START_CMD in .env
|
|
exec bash -c "${START_CMD:?no server.js found and START_CMD unset}"
|