How to use supervisor to process jobs in Laravel?

Viewed 5178

Im using laravel queue to dispach jobs and installed supervisor to hande them. Supervisor processes are working, they are running but not processing my jobs! Meanwhile if I run directly php artisan queue:listen jobs are executing! I created queue-worker in conf.d but still not working.

1 Answers
sudo apt-get install supervisor
cd /etc/supervisor/conf.d
vi laravel-worker.conf
[program:laravel-worker]
process_name=%(program_name)s_%(process_num)02d
command=/usr/bin/php /var/www/html/laravel/artisan queue:work database --sleep=3 --tries=3
autostart=true
autorestart=true
user=root
numprocs=5
redirect_stderr=true
stdout_logfile=/var/www/html/laravel/storage/logs/worker.log

Then :wq

sudo supervisorctl reread
sudo supervisorctl update
sudo supervisorctl start laravel-worker.conf

For more info you can see documentation https://laravel.com/docs/6.x/queues#supervisor-configuration

for the lines command=/usr/bin/php /var/www/html/laravel/artisan queue:work database --sleep=3 and stdout_logfile=/var/www/html/laravel/storage/logs/worker.log, replace /var/www/html/laravel with the path to your project

Related