In this article, we will see how to install Supervisor on AWS Elastic Beanstalk with Laravel.
• I assume you deployed your Laravel project on AWS Elastic Beanstalk & make all configurations of queue & etc.
• Connect to SSH.
• I'm using Amazon Linux 2 (Nginx server).
• PHP 7.4 installed on AWS.
After connect to ssh follow these steps:
The EPEL repository is an additional package repository that provides easy access to install packages for commonly used software.
$ sudo amazon-linux-extras install epel
Let's install supervisor run the following command.
$ sudo yum install -y supervisor
Go to the default configuration file.
$ sudo vim /etc/supervisord.conf
Change the include directory at the end to:
files = supervisord.d/*.conf
Add a new configuration file. If the directory doesn’t exist, then make one.
$ sudo vim /etc/supervisord.d/NameYouLike.conf
Give the setting:
[program:laravel-worker] process_name=%(program_name)s_%(process_num)02d command=php /var/app/current/artisan queue:work sqs --sleep=3 --tries=3 --max-time=3600 autostart=true autorestart=true stopasgroup=true killasgroup=true user=root numprocs=8 redirect_stderr=true stdout_logfile=/var/app/current/storage/worker.log stopwaitsecs=3600
command line, I'm using SQS for the queue, if you are using (Database or Redis) you should change it to the thing that you are using.
$ sudo supervisord -c /etc/supervisord.conf
Apply new setting and check the status
$ sudo supervisorctl update; $ sudo supervisorctl status
You should see something like that: