Member-only story

Laravel Queue work with supervisor on AWS EC2

Jangwook Kim
1 min readJun 10, 2021

--

1. Install a supervisor

In Amazon repository, there is no supervisor. So we should use epelrepository 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!

--

--

Jangwook Kim
Jangwook Kim

Written by Jangwook Kim

Korean, live in Japan. The programmer. I love to learn something new things. I’m publishing my toy projects using GitHub. Visit https://www.jangwook.net.

No responses yet

Write a response