Background workers and schedulers
A worker runs your app's code without a web address: a queue worker, a scheduler, or a WebSocket server. It deploys from the same repository as its service and shares its variables.
Add a worker
- Connect the service to GitHub first. The worker deploys from the same repository and branch.
- On the service, choose Add worker.
- Give it a name and a start command, then create it. It builds and starts on its own.
Common start commands
- Laravel queue
php artisan queue:work --tries=3- Laravel scheduler
php artisan schedule:work. Runs everything in your schedule, every minute.- Laravel Horizon
php artisan horizon. Only iflaravel/horizonis installed and the queue uses Redis.- Laravel Reverb
php artisan reverb:start --host=0.0.0.0 --port=8080- Node.js
- Your script, for example
node worker.jsornpm run worker. - Celery
celery -A app worker
Without a scheduler worker (or a cron job), scheduled tasks in your code never run.
Change the start command
Open the worker's Service settings, edit Start command, and choose Save and redeploy. The worker redeploys with the new command and Deployment Center shows the result. A stopped worker uses it when you start it.
How workers behave
- Every variable of the service reaches its workers as a reference, including keys added later. A value set on the worker itself is kept.
- Each push deploys the service and its workers together. They reuse one build of the same commit.
- A worker that crashes is restarted. Its output is in Logs, and Shell works on workers too.
- Deleting a service deletes its workers.
Plan limits
Workers added from a service don't count towards your plan's web services. Each plan includes a number of workers: Starter 2, Business 4, Scale 8.