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 crashes for any reason.
Step 1- Update all the packages
1 2 |
apt-get update -y |
Step 2- Install Supervisor
By default, the 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
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 |
vi /etc/supervisor/conf.d/nginx.conf |
Add the following lines:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
[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 |
supervisorctl reread |
You should get below output

Next, tell the supervisor to update its configuration:
1 2 |
supervisorctl update |

To verify whether the supervisor has started the nginx service or not run the below command
1 |
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 |
ps -aux | grep nginx |

You may also visit our Magento development services and quality Magento 2 Extensions.
For further help or queries, please contact us or raise a ticket.
Be the first to comment.