Supervisor config generator for Laravel
Keep queue workers, Horizon, Octane or Reverb running. The output follows the Supervisor examples in the Laravel 13 documentation, with the stop and kill settings that protect running jobs.
What each line is for
| Directive | Why it is there |
|---|---|
process_name | With more than one process, the name must include %(process_num). Supervisor refuses the file otherwise. |
stopwaitsecs | How long Supervisor waits after asking a process to stop. The default is 10 seconds, after which the process is killed mid-job. Set it above your longest job. |
stopasgroup, killasgroup | Send the stop and kill signals to the worker's child processes too, so none are left behind. |
redirect_stderr | Sends errors to the same log file as normal output. With it on, a separate stderr_logfile is ignored. |
autorestart | Starts the process again when it exits, which is what makes queue:restart and --max-time work. |
Three timeouts that have to agree
--timeoutis how long one job may run before the worker kills it.retry_after, inconfig/queue.php, is when the queue hands an unfinished job to another worker. Keep it several seconds longer than--timeout, or a slow job is processed twice.stopwaitsecsis Supervisor's patience during a stop. Keep it longer than--timeout.
Deploying new code
Workers are long-lived and keep the old code in memory. After each deploy, tell them to finish their current job and exit. Supervisor starts fresh ones.
php artisan queue:restart # queue workers
php artisan horizon:terminate # Horizon
php artisan octane:reload # Octane
php artisan reverb:restart # Reverb
Horizon, Reverb and the scheduler
- Horizon runs as one process. It starts and balances its own workers from
config/horizon.php, so there is nonumprocs. - Reverb holds one open file per connection. Raise the limit in the
[supervisord]section of the main Supervisor config withminfds=10000. - The scheduler does not belong in Supervisor. Laravel's documented production setup is one cron entry.
schedule:workis for local development.
* * * * * cd /path-to-your-project && php artisan schedule:run >> /dev/null 2>&1
Where the file goes
On Ubuntu and Debian, program files live in /etc/supervisor/conf.d/ and end in .conf. Other distributions use a different directory or extension, such as /etc/supervisord.d/*.ini. Check the [include] section of your main Supervisor config.
Sources: Laravel 13 documentation for queues, Horizon, Octane, Reverb and scheduling, and the Supervisor configuration reference.
Building a SaaS on Laravel? Start with the foundation already built.
Stack Toast is a Laravel 13 starter kit with authentication, billing through four payment processors, teams and a complete admin panel. Choose Livewire, React, Vue or API.
- From $199, one payment
- Full GitHub source
- Unlimited projects
- 30-day money-back guarantee
