Installing Supervisor¶
Note
If you don’t have root access to your server, ignore this section.
For Centos¶
Running following commands: 1. yum install supervisor
- vim /etc/supervisord.conf edit section program as following:
- [program:laravel-worker]command=php /path_to_source_folder/artisan queue:workprocess_name=%(program_name)s_%(process_num)02dnumprocs=8priority=999autostart=trueautorestart=truestartsecs=1startretries=3user=apacheredirect_stderr=true
stdout_logfile=/path/to/log/worker.log
systemctl enable supervisord to autorun at start
systemctl restart supervisord to restart the service
For Redhat/Debian¶
sudo apt-get install supervisor
Configuration
Supervisor configuration files are typically stored in the /etc/supervisor/conf.d directory. Within this directory, you may create any number of configuration files that instruct supervisor how your processes should be monitored. For example, let’s create a laravel-worker.conf file that starts and monitors queue:work processes:
[program:laravel-worker]process_name=%(program_name)s_%(process_num)02dcommand=php /path_to_source_folder/artisan queue:work –sleep=3 –tries=3 –max-time=3600autostart=trueautorestart=truestopasgroup=truekillasgroup=trueuser=forgenumprocs=8redirect_stderr=truestdout_logfile=/path_to_source_folder/worker.logstopwaitsecs=3600
In this example, the numprocs directive will instruct Supervisor to run eight queue:work processes and monitor all of them, automatically restarting them if they fail. You should change the command directive of the configuration to reflect your desired queue connection and worker options.
For more information on Supervisor, consult the Supervisor documentation.
- Final
- sudo supervisorctl rereadsudo supervisorctl updatesudo supervisorctl start laravel-worker:*