Queue Workers

Running and Supervising Queue Workers

queue:work boots once and loops; queue:listen boots a child per job, so it sees code changes, but nine 300 ms jobs took 9.1 s instead of 4.9 s. A work process keeps the code it booted with (an edited job still logged its old wording 18 times), so every deploy ends with php artisan queue:restart. Workers see its cache flag between jobs, log Worker STOPPED Received restart signal and exit, and a process manager restarts them: on a LAMP server, systemd 142,543 (Your Own Unit File).

/etc/systemd/system/shop-worker.servicePHP
[Unit]
Description=Bookshop queue worker
After=network.target mysql.service
[Service]
Type=exec
User=www-data
Group=www-data
WorkingDirectory=/var/www/shop
ExecStart=/usr/bin/php artisan queue:work --sleep=3 --tries=3 --max-time=3600
Restart=always
RestartSec=5
TimeoutStopSec=60
[Install]
WantedBy=multi-user.target

Restart=always also revives the worker after --max-time retires it hourly against memory leaks, and SIGTERM from systemctl stop lets the current job finish within TimeoutStopSec. After systemctl enable --now shop-worker, a kill -9 mid-job left this in journalctl -u shop-worker -o cat:

Output of 180
  2026-09-23 08:59:21 App\Jobs\SendOrderConfirmation ................. RUNNING
shop-worker.service: Main process exited, code=killed, status=9/KILL
shop-worker.service: Failed with result 'signal'.
shop-worker.service: Scheduled restart job, restart counter is at 1.
...
  2026-09-23 09:00:53 App\Jobs\SendOrderConfirmation ................. RUNNING

The new worker ran the other eight jobs, but the killed one stayed reserved until retry_after expired, 92 seconds later. A reboot restarts the enabled unit the same way. Laravel 2,157 's documentation uses Supervisor 4.3.0 121,801 instead (pm2, systemd or supervisord):

/etc/supervisor/conf.d/shop-worker.confPHP
[program:shop-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/shop/artisan queue:work --sleep=3 --tries=3 --max-time=3600
user=www-data
numprocs=2
autorestart=true
stopwaitsecs=60
stdout_logfile=/var/www/shop/storage/logs/worker.log

After supervisorctl reread and update, status showed shop-worker_00 and _01 RUNNING as PIDs 252053 and 252054; queue:restart replaced them with 252946 and 253075.