How to run`php artisan queue:work` in the background ?
to run the queue, I need to run php artisan queue:work but when I disconnect from the server this queue work is canceled !
I'm wondering what's the best way to keep php artisan queue:work running in the background of my server and how to be sure that it's not stopped ?
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.1 LTS
Release: 20.04
Codename: focal
Thanks
You will need to setup supervisor on your instance.
sudo apt-get install supervisor
cd /etc/supervisor/conf.d
vi laravel-worker.conf
-- paster the below code -- replace {project} with correct path
[program:laravel-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/html/{project}/artisan queue:work
autostart=true
autorestart=true
user=root
numprocs=1
redirect_stderr=true
stdout_logfile=/var/www/html/{project}/storage/logs/supervisord.log
sudo supervisorctl reread
sudo supervisorctl update
sudo supervisorctl start laravel-worker:*
Failing that run queue:listen instead and that will run a little longer.
Please or to participate in this conversation.