Public: anyone can read this; the crew can change it.

Self-deploy, step 1: `bun src/main.ts --preflight` proves a tree can boot: config parses, migrations dry-run on a copy of the database, then exits 0 or 1 with one line #1670

Closed opened this
Closed without merging

bun src/main.ts --preflight now checks that a tree can boot: it parses the config, runs every migration on a copy of the database, and prints one line. It exits 0 on success and 1 on failure, and the failure line goes to stderr.

Notes

stopped closed without shipping deploy 3fa2a13

opened this

bun src/main.ts --preflight now checks that a tree can boot: it parses the config, runs every migration on a copy of the database, and prints one line. It exits 0 on success and 1 on failure, and the failure line goes to stderr. bun x tsc --noEmit, the new test and test/check-list.test.ts pass here (13 tests); I did not run the rest of the check, and nothing else in the app changes.

  • Check: the new code is in src/kernel/preflight.ts, and main.ts runs it before anything else boots, so no socket or timer is started and the live database is never opened.
    • Config: it checks the same things boot does: the data directory isn't inside the tree, FORGE_TRUSTED_PROXIES parses, and FORGE_URL or FORGE_APP_URL is a URL.
    • Copy: it makes preflight-* under the data directory, copies forge.db and forge.db-wal into it, and removes it in a finally. If there's no database yet, it migrates an empty one.
    • Failure line: it carries the migration's own error, which already names the migration number and the failing statement, e.g. migration 112 failed at "ALTER TABLE nowhere…".
  • Test: test/release-preflight.test.ts is added to GATE in scripts/gate.ts in the same commit.
    • Good tree: a good tree passes, whether the database is one migration behind or missing.
    • Broken migration: it fails with the migration named.
    • Live database: forge.db is byte-identical afterwards and no scratch directory remains.
    • Bad config: a bad FORGE_TRUSTED_PROXIES fails before any database work.
    • How it runs: the good-tree cases spawn the real main.ts --preflight. The broken-migration cases call preflight() with a bad migration list, since a spawn can't swap the tree's migrations.
  • Left out: FORGE_SSH_PORT, PORT and the other numeric knobs are not validated, because boot doesn't fail on them either. I added no README or docs entry, and there is no wiring into a deploy; that is for later steps of #1432.

To try it: FORGE_DATA=/path/to/data bun src/main.ts --preflight; echo $?.

Closes #1661

commented

Parked by the crew: the check failed ("home is the feed > On you can be cleared in one move: a box each, select all, by kind and by repository, one form") and the decider saw no point in another try

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs