user7747472
user7747472

Reputation: 1952

Laravel 5.7 : Supervisorctl does not auto-restart queue worker with

I have supervisor for managing queue notifications as suggested in the laravel documentation . I have configured the supervisor as per the documentation and here is my configuration file.

[program:laravel-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/application/artisan queue:work --tries=3
autostart=true
autorestart=true
user=root
numprocs=8
redirect_stderr=true
stdout_logfile=/var/www/application/storage/logs/worker/worker.log

This works fine but the problem is after sometime all the workers stops and doesn't restart even though there is pending jobs to be completed.

I need to manually restart the supervisor using sudo supervisorctl start laravel-worker:*.

How can this be resolved ?

Supervisorctl does not auto-restart daemon queue worker when hanging This is similar problem but the solution given there is the same thing i am using here.

Can anyone please help ?

Upvotes: 1

Views: 1796

Answers (1)

Christophvh
Christophvh

Reputation: 13254

You could use horizon. horizon handles all this for you. https://laravel.com/docs/5.8/horizon

Example supervisor script for horizon:

[program:horizon]
process_name=%(program_name)s
command=php /var/www/application/artisan horizon
autostart=true
autorestart=true
user=root
redirect_stderr=true
stdout_logfile=/var/www/application/storage/logs/horizon.log

Also add this command to your deploy-process:

php artisan horizon:terminate

No need to restart it, supervisor does that for you.

Upvotes: 1

Related Questions