Member-only story
Laravel Queue work with supervisor on AWS EC2

1. Install a supervisor
In Amazon repository, there is no supervisor. So we should use epel
repository to install that.
sudo yum --enablerepo=epel install supervisor
2. Start supervisor
sudo service supervisord start
If you get this sentence Redirecting to /bin/systemctl start supervisord.service
, install was succeed.
3. Modify the supervisor config file
To add worker to supervisor, we should modify the supervisor config file.
sudo vi /etc/supervisord.conf
And add these contents.
[program:worker]
command=php /project-home/artisan queue:work
process_name=%(program_name)s_%(process_num)02d
numprocs=2
autostart=true
autorestart=true
user=root
redirect_stderr=true
stdout_logfile=/project-home/storage/logs/worker.log
Please do not forget to add worker.log
file into your log path.
touch /project-home/storage/logs/worker.log
4. Read supervisor config file
To read your new config file to supervisor, execute this command.
sudo supervisorctl reread
If you wrote config correctly, you could get this message.
worker: available
5. Restart supervisor
To apply your new config to supervisor, execute this command.
sudo service supervisord restart
And check worker is working.
sudo supervisorctl status
You can get this message. (probably your pid and uptime is different for me.)
worker:worker_00 RUNNING pid 1043936, uptime 0:00:10
worker:worker_01 RUNNING pid 1043937, uptime 0:00:10
6. Add supervisor auto restart config
sudo chkconfig supervisord on
Done!