ServerAvatarDocs
ApplicationsManaging an application

Workers

Keep queue workers, Horizon or any long-running command alive for a Git application, with restart-on-deploy and restart-on-crash.

A web request ends. Some work should not: a queue consumer, a scheduler, a Node process serving a server-side-rendered app. Workers is where you hand those commands to the server's process supervisor so they are started at boot, restarted when they die, and restarted after a deploy.

The Workers screen for demo-app with no workers yet, offering Add worker and a Custom command template

Until the first one exists the screen offers two routes to the same dialog: Add worker, or starting from the Custom command template.

Add a worker

The Add a worker dialog with Name, Processes, Type, Command, and toggles for Restart after deploy, Restart automatically if it stops and Enabled

FieldWhat it means
NameYour label for this worker, e.g. background-jobs.
ProcessesHow many copies of the command to run side by side. Defaults to 1.
TypeQueue worker, Horizon, or Custom for your own command.
CommandThe command to keep running. Use template fills in a known one.
Restart after deployOn by default — a deploy that changes the code restarts the worker so it picks it up.
Restart automatically if it stopsOn by default. The supervisor brings the process back if it exits.
EnabledOff leaves the worker configured but not running.

Advanced settings holds the rest: Working directory, Log file and Log level, how long to wait for the process to stop before killing it, Start with the server, and a box for Extra supervisord settings when you need a directive the form does not expose.

Run the real process, not a package manager

The same rule applies here as to a start command: npm start or composer run forks the real process, so the supervisor watches the wrapper and shutdown signals never reach your code. Give the command that is the process — node server.js, php artisan queue:work.

After it exists

Each worker gets a row with its state and controls to start, stop, restart, edit and delete it. Restart after deploy is the one worth leaving on: without it, a deploy updates the code on disk and your worker keeps running the version it loaded at boot — which is the kind of bug that takes a day to find.

Workers belong to one application and run as that application's system user, so a worker cannot reach another application's files.

On this page