Skip to content

Run the App ​

Start with one supervised ./bin/app process. It runs the enabled HTTP, worker, and scheduler roles together. The photo app uses this arrangement so its HTTP producer and workerpool worker share a queue.

Each split process starts an instance of the same App and constructs its own dependencies. Use a shared queue backend before separating HTTP producers and workers.

Common Processes ​

Supervise the built artifact from Deploy an App. Use forj dev for the source-aware development loop.

CommandProcess ownership
./bin/appAll enabled runtime roles, equivalent to ./bin/app run
./bin/app apiHTTP only
./bin/app workerWorkers for all configured queues
./bin/app schedulerScheduler only

For an additional App named admin, use ./bin/admin with the same commands. Each binary exposes commands for its enabled components. A CLI-only binary shows root help when launched without arguments.

Choose the Processes to Supervise ​

Keep one process when the roles share scaling, restart, and resource policies. Split the roles when those policies differ or the scheduler needs one owner while HTTP scales. The commands your supervisor starts determine the topology. App code and build flags stay the same.

Supervise the Combined Runtime ​

Start ./bin/app as one service. The runtime host starts the enabled roles concurrently. If one fails, the host cancels its siblings and returns the first failure with the runtime name. An HTTP bind failure therefore stops the workers and scheduler in that process too.

Supervise Split Runtimes ​

Start each explicit command as its own service. Configure shared backends for queues, cache, events, and files that must cross process boundaries. A process-local driver remains local after you split the commands.

Runtime Roles ​

HTTP ​

Use ./bin/app api for independent HTTP replicas. The generated internal/http package owns server and runtime policy. API_HTTP_HOST defaults to 0.0.0.0. Set it to 127.0.0.1 when a same-host reverse proxy owns public traffic. Set API_HTTP_PORT for the listener. The command also accepts --host, --port, and, when metrics are enabled, --metrics-port. Environment configuration keeps the supervised command stable.

For local HTTP-only development, stop any watcher or process using the same port, then run this from the Project root.

bash
forj api

Use forj admin api for the admin App. Startup logs report the bind address and route count. From another terminal, list registered methods, paths, and handlers without starting another listener.

bash
forj route:list

Use forj admin route:list for the additional App. Register application routes in app/routes.go or app/<name>/routes.go. Controllers translate requests and responses, while application services own business workflows. The owning App's Wire graph constructs controllers. Start with Your First Route to add an endpoint.

Routing covers the /api/v1 prefix and middleware. Framework routes include health, readiness, Swagger, metrics, and Lighthouse. Configure the listener through the HTTP environment settings. Configuration explains which changes require a restart or rebuild.

HTTP access logs include URI, method, status, latency, and client IP. Successful SPA requests are quiet by default. Use HTTP_SPA_ACCESS_LOG_ENABLED=true to diagnose asset delivery. See HTTP access logs before reducing request logging, and retain lifecycle logs and runtime telemetry.

Workers ​

Use a shared backend on both producers and workers. The local workerpool driver cannot deliver a job from ./bin/app api to ./bin/app worker. Include the selected driver in QUEUE_SUPPORTED_DRIVERS, configure its connection settings, and regenerate the queue wiring before building the release. Check the driver's durability when jobs must survive restarts.

To give selected queues their own capacity, supervise this command.

bash
./bin/app worker --queue emails --queue reports

Repeat --queue for each logical queue the process owns. Named queues inherit the root driver unless overridden. Configure concurrency through QUEUE_WORKERS or QUEUE_<NAME>_WORKERS. Give busy queues more capacity or dedicated processes, then scale those processes independently. See queue configuration and the queue environment settings.

Queue administration depends on the backend. Redis supports the full administration contract. Other drivers can return unsupported errors for list, retry, cancel, delete, clear, or history operations. Check the queue driver capabilities before depending on those controls.

Scheduler ​

Keep one scheduler owner per App unless schedules use deliberate shared locking. Every combined replica also starts its enabled scheduler. Stable schedule names identify work but provide no locking. WithoutOverlapping() prevents overlap within one scheduler process. Use WithoutOverlappingWithLocker(...) with a shared locker to coordinate processes. See scheduler production behavior.

Register schedules in app/schedules.go or app/<name>/schedules.go. Registration errors exit before the scheduler loop starts. The Scheduler started log proves registration and startup completed. Verify an actual due run separately.

Cron and calendar schedules use the App timezone configured through APP_TZ. Scheduled tasks continue during HTTP maintenance mode. Pause them through scheduler controls when the deployment requires it. Dispatch long or retryable work to a queue. A failed scheduled run does not create a durable retry queue.

Runtime Defaults ​

Default ports follow App order, with the default App first and additional Apps in alphabetical order. Enabled components determine which listeners exist.

AppHTTPApp or HTTP metricsScheduler metricsWorker metrics
app3000100001000110002
First additional App3001100101001110012
Second additional App3002100201002110022

Use App-prefixed overrides such as ADMIN_API_HTTP_PORT=3100 and ADMIN_METRICS_PORT=10110. In split deployments, assign distinct reachable metrics endpoints to every process sharing a network namespace. A shared METRICS_PORT override can also affect worker and scheduler fallback ports. See metrics endpoints and port overrides.

Observability Identity ​

Keep one App identity across its processes and identify each role and replica separately through APP_INSTANCE_ID. Metrics include app and source. The local observability stack adds process, service, and environment at scrape time. See metrics labels.

When enabled, metrics record requests, job attempts, and scheduled runs. Inspects capture recent executions with bounded retention. Keep durable audit records separately. Use route patterns for HTTP metric dimensions and stable queue, job, and schedule names for background work.

Verify Runtime Work ​

Start each supervised command as its deployment service account. From another terminal, inspect the release binary.

bash
./bin/app about

Confirm the App identity, queue drivers, logical and backend queue names, worker counts, and effective timeout values. Use ./bin/admin about for the admin App.

Verify HTTP through health and readiness probes. Dispatch one safe job through the normal application path and confirm that the selected worker records its name and successful outcome. When available, check the attempt metrics, Inspect, and removal from pending work.

For schedules, confirm Scheduler started appears once for the intended owner. Check stable names and next-run metadata in Lighthouse when enabled. Let a safe schedule become due and confirm its logs, metrics, or Inspect outcome. Do not shorten a production schedule to create a probe. Process existence and startup logs alone do not prove work completed.

Shutdown ​

Send SIGINT or SIGTERM through the supervisor. Remove HTTP instances from traffic before stopping them so active requests can drain.

SettingDefaultShutdown behavior
APP_SHUTDOWN_TIMEOUT30sHTTP and scheduler shutdown, plus App lifecycle cleanup
QUEUE_SHUTDOWN_TIMEOUT10sWorker drain, capped at the App budget
SCHEDULER_SUBPROCESS_SHUTDOWN_TIMEOUTApp budgetScheduler-owned App command cleanup, capped at the App budget
SCHEDULER_COMMAND_TIMEOUT10mExecution limit for one scheduled command task

Unset or non-positive child shutdown budgets inherit the App budget. about reports effective values and capped settings. A child subprocess cannot extend a live parent deadline. See shutdown configuration.

In combined mode, runtime roles stop concurrently before outer lifecycle cleanup. Set the supervisor stop timeout above the complete shutdown path, including cleanup after runtime roles stop. Test with in-flight requests and jobs. Increasing the queue timeout beyond the App budget cannot extend worker drain. Forced termination can cause broker redelivery, so job idempotency remains necessary.

A normal scheduler stop logs Shutting down scheduler, followed by Scheduler shut down. A shutdown timeout returns an error. Confirm those messages and the worker drain finish before the supervisor forces termination. Put app-owned startup and cleanup hooks in app/lifecycle.go.

Failure Modes ​

SymptomOperator action
HTTP or metrics listener cannot bindFind the conflicting listener or assign a distinct port. A failed role cancels siblings in combined mode.
Liveness passes while readiness failsKeep the instance out of traffic and inspect the failed dependency through readiness diagnostics.
Worker cannot start or receive jobsCheck the compiled driver, shared backend connection, selected logical queue, and about inventory.
Delivery reports an unregistered handlerCheck app/wire/inject_jobs_app.go, rebuild, and restart workers before redispatching.
Queue depth grows or jobs repeatedly failInspect backend health and handler errors before adding capacity or retrying terminal jobs.
Schedule registration failsCorrect the interval, cron expression, name, or App wiring before restarting.
Due work runs more than onceRestore one scheduler owner or configure shared locking. Make interrupted work safe to rerun.
A command task exceeds its limitBound the work or move long, retryable work to a queue.
Shutdown exceeds its budgetAlign the App, child, and supervisor budgets, then repeat an in-flight shutdown check.

Continue with Deploy an App for release verification, traffic changes, and maintenance mode.