Set up Supervisor for laravel queue on MacOS and Linux



Image result for mac laravel

1- Installation  


for linux
  • $sudo apt-get install supervisor
for macos 
  • $sudo apt-get install supervisor

2- Configuration 


you can refer to the supervisor docs http://supervisord.org/configuration.html



the application will look for a file named supervisord.conf within the following locations, in the specified order. It will use the first file it finds.
  1. $CWD/supervisord.conf
  2. $CWD/etc/supervisord.conf
  3. /etc/supervisord.conf
  4. /etc/supervisor/supervisord.conf (since Supervisor 3.3.0)
  5. ../etc/supervisord.conf (Relative to the executable)
  6. ../supervisord.conf (Relative to the executable)

3- Setup for Laravel 




nano /etc/supervisor/supervisord.conf

Give it execute permissions: 

chmod +x queue.conf.



[program:laravel-worker]
autostart=true
autorestart=true
stderr_logfile=/var/log/laraqueue.err.log
stdout_logfile=/var/log/laraqueue.out.log
command=php /Applications/MAMP/htdocs/Genesis/artisan queue:work --tries=1 --ti$
numprocs=3
redirect_stderr=true
process_name=%(program_name)s_%(process_num)02d

[supervisord]
nodaemon=true

[supervisorctl]


In this example, the numprocs directive will instruct Supervisor to run 8 queue:work processes and monitor all of them, automatically restarting them if they fail. Of course, you should change the queue:work sqs portion of the command directive to reflect your chosen queue connection.

4- run supervisor


then run 
 sudo supervisord -c /etc/supervisor/supervisord.conf





Comments