Deployment
One build serves every instance: the same compiled output runs as an HTTP server, an optional worker, and a release task. The repository ships the process definitions; where they run is your choice.
Procfile
web: node dist/index.js
worker: node dist/worker.js
release: npm run db:migrate:prodProcess-file platforms (Heroku and compatible buildpack hosts are one example) read this file directly; elsewhere map the three lines to your own process definitions.
web— the Koa HTTP server (src/index.ts).worker— the NATS consumer (src/worker.ts). Run it only whenNATS_ENABLED=true: with NATS off, the worker gets the dummy client, skips its consume loop and the process ends. Scale it to 0 (or leave it out) for instances without NATS.release— run once per deploy, before the new code takes traffic: knex migrations against the compileddist/knexfile.js.
Startup order, the failures that stop each process and what SIGINT / SIGTERM do are on
Process lifecycle.
The release step
db:migrate:prod (package.json) is a shell one-liner with three outcomes, decided by the
shell environment variable APP_DISABLE_PERSISTENCE, not by the merged settings:
APP_DISABLE_PERSISTENCE | Result |
|---|---|
true | prints “Skipping migration” and exits 0 — a database-less instance deploys without a database |
unset, empty or false | runs db:jsts_check, then knex migrate:latest |
| any other value | runs nothing and exits non-zero, which fails the release |
Two consequences:
- A preset that sets
disable_persistence: truedoes not, by itself, skip the release migration. Set the env var as well for instances without a database (see Configuration Resolution). db:jsts_check(scripts/jsts_check.sh) compares the file counts ofsrc/migrationsanddist/migrations; when they differ and no terminal is attached it runsnpm run buildfirst, so a new migration is compiled before it is applied.
Build
npm run build = clean, then tsc into dist/. The runtime is plain Node (no ts-node in
production); the process commands above run dist/ output.
Environment specifics
- Secrets are environment-only. API keys, database and CRM credentials, XFF tokens
and OAuth secrets come from the process environment; nothing secret is committed. Env
files (
.env.<instance>) are for local runs. - TLS to the database. Set
DB_USE_SSL=truefor managed Postgres services that require TLS (Heroku Postgres is one example); the connection option is insrc/config.ts(db.connection.ssl). - Redis.
REDIS_URLis read first andREDISCLOUD_URLis only the fallback, so an add-on that injectsREDISCLOUD_URLis ignored whileREDIS_URLis set. Redis is used only whenREDIS_KEYV_ENABLE=true. - Cloud logging credentials. Unless
APP_ENVIRONMENTis the literallocalhost(unset counts as not localhost) the server refuses to start withoutGOOGLE_CREDENTIALS(src/config.ts). Platforms that hand secrets over as environment content need a startup step that writes it to a file where the logging client expects one (a process-start hook such as a.profilescript, where the platform runs one). - JWT keys are files named by
JWT_PRIVATE_KEY/JWT_PUBLIC_KEY; thekeys/directory is never in git, so the deploy must put the key files on disk. - Required at start:
REPLIERS_API_KEY,MAPBOX_ACCESS_TOKEN,JWT_PRIVATE_KEY,JWT_PUBLIC_KEY— the process asserts them at import.
Per-instance configuration (which env vars, which preset) is covered in Instances; what a pipeline should do before and after a deploy is in CI/CD.