What is Supervisor
It is a client/server system that allows users to control several processes running on a UNIX-like operating system. It is a free and open-source process management system. However, It restarts the processes if it got crashes for any reason.
To know more about the supervisor and its various version releases Click here!
Step 1- Update all the packages
1 |
apt-get update -y |
Step 2- Install Supervisor
By default supervisor package is present in the ubuntu 20.04 repository. Install it with the below-mentioned command
1 2 |
apt-get install supervisor -y |
After installing it you can check its version by running the below command
1 |
supervisord -v |
Verify the status of the service by running the below command
1 |
systemctl status supervisor |
Step 3- Manage the Nginx process with the supervisor
First, we need to install the nginx server with the below command
1 2 |
apt install nginx -y |
You must halt and disable the nginx service after installing it since we will use a supervisor to manage the nginx process.
You can stop and disable the nginx service with the following command:
1 2 3 4 |
systemctl stop nginx systemctl disable nginx |
Step 4- Create a conf file under the supervisor to serve nginx process
Now, for each service that you wish to manage, you must generate a separate configuration file. The following command will generate an nginx configuration file:
1 2 3 4 |
vi /etc/supervisor/conf.d/nginx.conf |
Add the following lines:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
[program:nginx] command=/usr/sbin/nginx -g "daemon off;" autostart=true autorestart=true startretries=5 numprocs=1 startsecs=0 process_name=%(program_name)s_%(process_num)02d stderr_logfile=/var/log/supervisor/%(program_name)s_stderr.log stderr_logfile_maxbytes=10MB stdout_logfile=/var/log/supervisor/%(program_name)s_stdout.log stdout_logfile_maxbytes=10MB |
After adding the above lines to the file. Now save and close the file.
Next, tell the supervisor to know about the new config:
1 2 3 4 |
supervisorctl reread |
You should get below output
Next, tell the supervisor to update its configuration:
1 2 3 4 |
supervisorctl update |
To verify whether the supervisor has started the nginx service or not run the below command
1 2 3 4 |
supervisorctl status |
You should get the below output
To stop the nginx service run the below command
1 |
supervisorctl stop nginx:nginx_00 |
To start the nginx service run the below command
1 |
supervisorctl start nginx:nginx_00 |
You can also verify the nginx process by the below command
1 2 3 4 |
ps -aux | grep nginx |
For Magento 2 Elastic search, please follow the –
Our Cloudkul Blogs
Elasticsearch, Fluentd, and Kibana (EFK)
Setting up Elasticsearch, Logstash, and Kibana for centralized logging
Managing and Monitoring Magento 2 logs with Kibana
Our store modules –
You may also visit our Magento development services and quality Magento 2 Extensions.
For further help or query, please contact us or raise a ticket.