Setting Laravel's Queue with Supervisor
Setting Laravel's Queue with Supervisor
Jason Jason Photo By Jason Jason, Aug 22, 2016

After upgrading our servers from Ubuntu 14.04 LTS to Ubuntu 16.04 LTS, it seemed like just about everything needed to be checked to make sure it was working. I just wrote a brief article on how to get PHP 7 up and running on Ubuntu 16.04, and after verifying that all my websites were up and running, it was time to make sure all the queued jobs were being executed properly. Laravel has a queue process that I like to manage with a program called Supervisor. Normally, supervisor seems to work great, but after upgrading and rebooting, it seemed like none of Laravel's queued jobs were running. Here are the steps I took to get everything back up.

Commands

sudo apt-get purge supervisor

sudo apt-get install supervisor

sudo service supervisor start

sudo supervisorctl reread

sudo supervisorctl update

sudo supervisorctl start laravel-worker:*

Sample Worker File

This should be saved in /etc/supervisor/conf.d/jj.conf

[program:jj]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/jj/laravel/artisan queue:work database --sleep=3 --tries=3 --daemon --queue=high,default,low
autostart=true
autorestart=true
user=www-data
numprocs=1
redirect_stderr=true
stdout_logfile=/var/www/jj/laravel/storage/logs/supervisor/queue.log

References

https://laravel.com/docs/5.2/queues#supervisor-configuration

http://supervisord.org/

https://www.digitalocean.com/community/tutorials/how-to-install-and-manage-supervisor-on-ubuntu-and-debian-vps


Tags & Categories

Laravel Command Line Linux PHP