In this blog, I’ll Walk you through how I set up a custom monitoring system for Supervisor-managed processes like Nginx and Apache2, this setup will allow you to track the health and performance of processes running under Supervisor in real time.
What Is Supervisor?
Supervisor is a process control system that allows users to manage and monitor numerous processes.
Step 1 Install Supervisor
you can install it using this command:
sudo apt update
sudo apt install supervisor
*Step 2 Configure Supervisor for Nginx and Apache
*
- Once Supervisor is installed, you’ll need to create configuration files for Nginx and Apache.
For Nginx
- Create a file in this path in this format /etc/supervisor/conf.d/nginx.conf/.
One-line Summary for NGINX (Supervisor Configuration)
- This Supervisor configuration enables effective management of the NGINX service by running it in the foreground, ensuring automatic startup, handling unexpected failures through automatic restarts, and directing logs to specified output and error files.
[program:nginx]
command=/usr/sbin/nginx -g "daemon off;"
autostart=true
autorestart=true
stderr_logfile=/var/log/nginx.err.log
stdout_logfile=/var/log/nginx.out.log
For Apache
- Create another file on this path in this format /etc/supervisor/conf.d/apache2.conf.
One-line Summary for Apache (Supervisor Configuration):
- This Supervisor configuration enables effective management of the Apache service by running it in the foreground, ensuring automatic startup, handling failures through automatic restarts, and storing standard output and error logs in specified files.
[program:apache2]
command=/usr/sbin/apachectl -D FOREGROUND
autostart=true
autorestart=true
stderr_logfile=/var/log/apache2.err.log
stdout_logfile=/var/log/apache2.out.log
[ Good Read: Best Automated Cloud Deployment Services]
Step 3 Reload Supervisor and Start Services
- Once the configurations are created, updated, we need to reload Supervisor to apply these changes and start both services.
sudo supervisorctl reread
sudo supervisorctl update
sudo supervisorctl start nginx
sudo supervisorctl start apache2
Step 4 Check the Status of Nginx and Apache.
Now check if the Supervisor is managing Nginx and Apache or not. If it does you will see the output like below.
sudo supervisorctl status
- You should see output like:
nginx RUNNING pid 1234, uptime 0:01:10
apache2 RUNNING pid 5678, uptime 0:01:10
*Step 5 Create a Python Script for Monitoring with Open Telemetry and Prometheus. *
- I have created a Python script to gather performance metrics of the processes under Supervisor.
You can check more info about: How does OpenTelemetry work with Supervisor?.
**- AWS Consulting.