Skip to content
On this page

BY NOW

Get your script now!

Supervisor Configuration

We need supervisor to manage running jobs in the background. This need to mail server if you use a custom mail server and is important for generating responsive images.

For example install Supervisor on CentOS/Alma/Rocky

The Supervisor package exists in the EPEL package repository. So, we need to install EPEL first and then supervisor:

bash
# on cenots 8, you can use dnf instead of yum
sudo yum install epel-release -y
sudo yum install supervisor -y

Enable and start the supervisord service:

bash
sudo systemctl enable supervisord
sudo systemctl start supervisord

Now check the status:

bash
sudo systemctl status supervisord

In  /etc/supervisor/conf.d  (Debian/Ubuntu) or  /etc/supervisord.d/ (Red Hat/CentOS)create a file worker.conf.

You need to edit PHP path, project path, and user if need.

If you use aapanel use this config:

bash
[program:worker]
process_name=%(program_name)s_%(process_num)02d
command=php /www/wwwroot/example.com/artisan queue:work --sleep=3 --tries=3
autostart=true
autorestart=true
stopasgroup=true
killasgroup=true
numprocs=1
redirect_stderr=true
stopwaitsecs=3600

# If you want to collect supervisor errors you need to add this line in config and create worker.log file in the log folder
stdout_logfile=/www/wwwroot/example.com/storage/log/alma-worker.log

If you don't use specific vps panel use this config:

bash
[program:worker]
process_name=%(program_name)s_%(process_num)02d
command=/usr/bin/php /var/www/example.com/artisan queue:work --sleep=3 --tries=3
autostart=true
autorestart=true
stopasgroup=true
killasgroup=true
user=www-data
numprocs=1
redirect_stderr=true
stopwaitsecs=3600

# If you want to collect supervisor errors you need to add this line in config and create worker.log file in the log folder
stdout_logfile=/www/wwwroot/example.com/storage/log/alma-worker.log

Now reload the supervisord service:

bash
# reload the changes
sudo supervisorctl reread

# restart supervisor & reload the changes
sudo supervisorctl update

# check status (all running services)
sudo supervisorctl status