Deploy an App
Deploy a compiled app binary with production configuration, run its migrations once, and verify the running release before sending traffic. Keep the previous artifact available until those checks pass.
Before You Start
Start with a working app, such as Save and List Photos. Provision its production database, queue, cache, and storage. Your deployment platform must provide secret delivery, DNS, TLS, network policy, and process supervision.
Choose a build environment compatible with the production operating system and architecture. Test native dependencies on that platform.
Build the Release
From the Project root, build the default app.
forj buildThe command creates executable bin/app. It refreshes Project files, builds stale configured SPAs, runs Wire, prepares the API index, and compiles the app.
SPAs must be configured under dev.apps to participate in the build. The binary embeds the app's frontend output. Keep the tested artifact immutable and verify its checksum or image digest after transfer.
For an additional app named admin, run forj admin build. Expect executable bin/admin. Build every app included in the release.
Configure Production
Supply configuration through the process environment or your platform's secret store. An HTTP deployment behind a controlled container network can start with these settings.
APP_ENV=production
APP_DEBUG=0
APP_URL=https://api.example.com
API_HTTP_HOST=0.0.0.0
API_HTTP_PORT=3000
APP_SHUTDOWN_TIMEOUT=30s
APP_DIAG_TOKEN=<value-from-your-secret-store>Use API_HTTP_HOST=127.0.0.1 when a reverse proxy on the same host owns public traffic. See the Environment Reference for driver settings and the App timezone. Apply Production Hardening.
Place SQLite databases, uploads, and other durable files outside the release directory. Configure absolute paths so process replacement opens the same data. Keep backup output outside the release directory too.
The photo app's workerpool queue keeps pending work in memory and requires the HTTP producer and worker to share a process. Configure a shared queue backend before splitting workers or requiring pending jobs to survive restarts. A driver change leaves existing queued work in its original backend.
Start Supervised Processes
For the combined runtime, supervise the built binary.
./bin/appA runtime-capable binary selects run and starts its enabled HTTP, worker, and scheduler runtimes. Run the App covers split processes and shutdown budgets.
Run the process as an unprivileged identity. Collect standard output and standard error, define a restart policy, and deliver SIGTERM during shutdown. Remove an instance from traffic before stopping it. Test the supervisor's stop grace period with in-flight work and allow time for the complete shutdown path.
Keep one scheduler owner unless schedules use deliberate cross-process locking. Split processes need shared drivers for the work and state they exchange.
Prepare the Data
Runtime startup leaves database migrations to an explicit command. Create and verify a recovery point before running migrations from the staged release.
/srv/example/releases/2026-12-03/bin/app migrateExpect the command to exit successfully before that release receives traffic. Run it once per migration-owning app. Use additive schema changes that support both binaries during a rolling deployment.
Activate the Release
Separate the release artifact, configuration, and mutable state.
/srv/example/releases/2026-12-03/ immutable release
/srv/example/current active release reference
/etc/example/app.env configuration and secrets
/var/lib/example/ durable local data
/var/backups/example/ backup setsUpdate the active release reference or deploy the image through your platform. Ask the supervisor to replace each process. For each HTTP replica, remove it from traffic, start the release, complete the checks below, and return it to traffic.
Drain workers before changing queued payload or handler contracts. Keep scheduler ownership singular throughout the rollout.
Verify Before Sending Traffic
Check the staged binary's routes before starting its listener.
./bin/app route:listExpect the routes registered by this release. After the supervisor starts the process, run these checks from another terminal with the operator environment loaded.
./bin/app health --url http://127.0.0.1:3000 --timeout-ms 10000 --failExpect ready, HTTP 200, and exit status zero. Health Checks covers liveness, dependency diagnostics, and probe timeouts.
When metrics are enabled on the combined HTTP runtime, check its scrape endpoint.
curl --fail http://127.0.0.1:3000/metricsExpect Prometheus text output. Metrics lists endpoints for split processes.
Complete an application smoke check that reads existing data and exercises required dependencies. For the photo app, request its saved metadata.
curl --fail http://127.0.0.1:3000/api/v1/photosExpect the JSON array to contain records saved before deployment. An unexpected empty array can mean the process opened a different SQLite file. If you added the photo worker, verify dispatch and execution with a saved ID.
Roll Back Safely
If a check fails, remove the release from traffic. Restore the previous artifact, restart its processes, and repeat the probes and application smoke check. Preserve the failed release's logs and diagnostics.
WARNING
A binary rollback leaves database migrations in place. Preserve schema compatibility and ensure the previous worker understands queued payloads before relying on artifact rollback.
Use Maintenance Mode
Run maintenance commands in the HTTP runtime's host or container network namespace, with its environment and APP_DIAG_TOKEN available.
./bin/app maintenance:enableThe command calls the running app over loopback without booting its dependency graph. New application requests return HTTP 503. Browser navigation receives a maintenance page, while API and explicit JSON clients receive a JSON error. In-flight handlers can finish. Workers and scheduled tasks continue.
Health, readiness, metrics, and Lighthouse remain available when enabled. Readiness can pass during maintenance, so remove maintenance instances from traffic through your deployment policy.
Verify an application request returns HTTP 503. After the operation, restore service without rebuilding the binary or frontend.
./bin/app maintenance:disableExpect application requests to resume. Additional apps own separate state and commands, such as ./bin/admin maintenance:enable.
Use APP_MAINTENANCE_DRIVER=cache with a shared, persistent cache backend in production. APP_MAINTENANCE_STORE selects an existing generated resource and defaults to default. For example, operations reuses CACHE_OPERATIONS_* settings and connections. The local memory default affects one process and loses its state on exit.
Cache state is isolated by a one-way namespace derived from APP_KEY, APP_ENV, and the app name. If you rotate APP_KEY or change APP_ENV while maintenance is active, enable maintenance again in the new namespace.
APP_MAINTENANCE_ENABLED=true forces maintenance at startup. To resume service, clear that setting and restart the affected processes.
WARNING
The control route requires the diagnostic token and accepts only loopback peers. Other peers receive an empty HTTP 404. If a proxy or sidecar connects over loopback, deny /-/maintenance/* at that proxy so public clients cannot reach the control route through it.
Failure Modes
| Symptom | Operator action |
|---|---|
| The release serves an old frontend | Check dev.apps, refresh source modification times if external tooling preserved them, and rebuild. |
| Health passes and readiness fails | Inspect the authorized probe's failed dependency check. |
| A migration is missing | Run migrate from the staged release for the owning app. |
| Saved data disappears | Check the absolute database and storage paths before accepting writes. |
| Shutdown ends in a forced kill | Measure in-flight work and increase the supervisor's stop grace period. |
Production Checklist
Before sending traffic, confirm the release meets these conditions.
- Every deployed app and configured frontend uses the tested artifact.
- Production drivers and stable data paths are configured.
- A verified backup exists and compatible migrations have completed once.
- Required processes have supervisors, tested shutdown budgets, and one scheduler owner.
- Readiness, metrics, and an application smoke check pass.
- The previous artifact supports the deployed schema and queued payloads.
Next Steps
Use Run the App for process ownership and shutdown. Use Health Checks and Metrics to configure deployment checks. Backup and Restore covers recovery. For investigations, use Logging, Inspects, and Lighthouse.