Install & Setup Supervisor
In this short snippet, you will learn how to install and manage Supervisor in Ubuntu machine. The steps is very straight forward so let's get started.
Step 1: Install Supervisor in Linux
Ubuntu
To install supervisor in ubuntu you can use "apt-get" command line. Do note that you need to use "sudo" in order to run this command.
sudo apt-get install supervisorCentOS
To install supervisor in centOS (used by most whm server) you can use "yum" command line. Do note that you need to use "sudo" in order to run this command.
sudo yum update -y
sudo yum install epel-release
sudo yum update
sudo yum -y install supervisorThen start and enable the supervisord daemon to start on boot using the commands below:
sudo systemctl start supervisord
sudo systemctl enable supervisordStep 2: Supervisor Configuration
The supervisor configuration can be located in "/etc/supervisor/conf.d" or "/etc/supervisord.d" (in centOS) and from within this directory, you can create as many configurations as you like.
For this example, we'll set up Laravel Queue supervisor configuration. To create a new file from within the supervisor config directory called "queue_manager.conf" or "queue_manager.ini" and the content of the file should be as follows.
Create the config file using the command below:
Ubuntu
nano /etc/supervisor/conf.d/queue_manager.confCentOS
nano /etc/supervisord.d/queue_manager.iniThen paste the follow code in the file:
[program:laravel_queue]
process_name=%(program_name)s_%(process_num)02d
command=php /PATH_TO_YOUR_BACKEND/artisan queue:work --tries=1
startsecs = 0
autostart=true
autorestart=true
user=root
numprocs=1
redirect_stderr=true
stderr_logfile=/PATH_TO_YOUR_BACKEND/storage/logs/laraqueue.err.log
stdout_logfile=/PATH_TO_YOUR_BACKEND/storage/logs/laraqueue.out.log
stderr_logfile_maxbytes=1MB
stdout_logfile_maxbytes=1MBIn the code above, you have to replace the following with the right values on your server: PATH_TO_YOUR_BACKEND replace with the directory path of where you backend files is location, usually its something like home/USERNAME/public_html
user=forge, change it to the user you are logged in in your terminal, usually is root user, so you can set: user=root
Step 3: Start Supervisor
Once you have created the configuration, you can start the supervisor process. To start supervisor you can run the following commands.
sudo supervisorctl reread
sudo supervisorctl updateStep 4: Start the queue
Run the command below to start just the laravel_queue you just created above
sudo supervisorctl start laravel_queueNote: If nothing works after run the command above, you can rather run the command below, to make supervisor start all queue:
sudo supervisorctl start allDone!!
Last updated
Was this helpful?