Supervisor: A Process Control System

Supervisor: A Process Control System


STEPS :
1. Introduction to supervisor
2. installation
3. web panel
4. adding services like nginx
5.. summery



Introduction to supervisor

Supervisor is a client/server system that allows its users to monitor and control a number of processes on UNIX-like operating systems.
It shares some of the same goals of programs like launchd, daemontools and runit. Unlike some of these programs, it is not meant to be run as a substitute for init as “process id 1”. Instead it is meant to be used to control processes related to a project or a customer, and is meant to start like any other program at boot time. launchd, daemontools and runit.


for detail information visit official website of supervisor (link below) - 

Overview

Supervisor is a client/server system that allows its users to control a number of processes on UNIX-like operating systems.It was inspired by the following:
Convenience -  
rc.d scripts cannot automatically restart a crashed process and many programs do not restart themselves properly on a crash. 
 Supervisord starts processes as its sub processes, and can be configured to automatically restart them on a crash.


 It can also automatically be configured to start processes on its own invocation.
automated

Accuracy
It’s often difficult to get accurate up/down status on processes on UNIX. Pidfiles often lie. Supervisord starts processes as subprocesses, so it always knows the true up/down status of its children and can be queried conveniently for this data.

Features

Simple
Centralized
Efficient
Extensible
Compatible
Proven

for more detail visit :    http://supervisord.org/introduction.html

Supervisor Components

supervisord
supervisorctl
Web Server
XML-RPC Interface

for more detail visit :   http://supervisord.org/introduction.html

Platform Requirements

Supervisor has been tested and is known to run on Linux (Ubuntu 9.10), Mac OS X (10.4/10.5/10.6), and Solaris (10 for Intel) and FreeBSD 6.1. It will likely work fine on most UNIX systems. 
Supervisor will not run at all under any version of Windows.
Supervisor is known to work with Python 2.4 or later but will not work under any version of Python 3. 
also work fine on redhat and centos distro   ## add 

Installation :

First we need to install nginx package and in yum repository we cannot find nginx package. So we need to install another package which contain different packages like nginx which is not present in yum repository. Basically "epel-release" creates new repository.
#yum install epel-release -y
 Now, after successful installation of "epel-release" we will install nginx package which is used for server.
#yum install nginx -yif you want to know more about nginx visit : https://www.nginx.com/resources/admin-guide/
 after installation of nginx, we will start and enable nginx service and check wheather is working or not.
#systemctl start nginx
#systemctl enable nginx
 now, we check the status of nginx service,
#systemctl status nginx
 now go to web browser and search for ip address of your server.
-> http://ip_address_of_your_server
now we will install dependency package for supervisor,
#yum install python-pip -y
 using pip we will install supervisor, and implementing supervisor
#pip install supervisor
 now we will create supervisord folder containing another folder [ directory ] using mkdir command
#mkdir -p /etc/supervisord/conf.d
 now we will create configuration file under /etc/supervisord/ of name supervisord.conf and reflect content using "echo_supervisord_conf " command
#echo_supervisord_conf > /etc/supervisord/supervisord.conf
#echo "files = conf/*.conf" >> /etc/supervisord/supervisord.conf

now we will install another dependency of supervisor which is wget.
#yum install wget -y
note: GNU Wget (or just Wget, formerly Geturl, also written as its package name, wget) is a computer program that retrieves content from web servers. It is part of the GNU Project. Its name derives from World Wide Web and get. It supports downloading via HTTP, HTTPS, and FTP.
Its features include recursive download, conversion of links for offline viewing of local HTML, and support for proxies.
 now using wget we will fetch binary files or programming files for supervisord and create service under /usr/lib/systemd/system/supervisord.service
#wget https://gist.githubusercontent.com/mozillazg/6cbdcccbf46fe96a4edd/raw/2f5c6f5e88fc43e27b974f8a4c19088fc22b1bd5/supervisord.service -O /usr/lib/systemd/system/supervisord.service
now after installation, we will start service and enable service and check status of supervisord service.
#systemctl start supervisord
#systemctl enable supervisord
#systemctl status supervisord
 now we will change in supervisord configuration file enable web panel.
so to enter change, we need to first visit location "/etc/supervisord/supervisord.conf"
#vi /etc/supervisord/supervisord.conf
 you will see in below picture having blue border around few lines,
change to this -> 
 now go to web panel and check for ip address and port number which you defined in configuration file and you can visit the supervisor page asking for username and password.
 after giving the credential, it will show zero program because by default there is not service is present in supervisor.
 now go to configuration file of supervisord
# vi /etc/supervisord/supervisord.conf
 add few lines in the bottom of the file for nginx service,
[program:nginxgo]
command = /usr/sbin/nginx
autostart=true
autorestart=unexpected
exitcodes=0
stdout_logfile=/var/log/nginx/access.log
stderr_logfile=/var/log/nginx/error.log
now save and stop the nginx service because we will use supervisord to control the start/stop operation of different service present in system or server.
#systemctl stop nginx
#systemctl status nginx 
[ inactive ]
now after stopping nginx, we will restart supervisord for implementing the changes,
#systemctl restart supervisord
#systemctl status supervisord 
 now go to web browser and restart the supervisord tab,
 you will see that their is one service name - nginxgo [ you can change in configuration according to you ] 
In this panel you can restart alll service / stop all service. and also check the status of different services under supervisord service.
 in each service present in supervisord,
you can restart the service , also stop the service.
you can also clear log present in server of that service and also visualize or monitor the logs using " tail -f " press button in action tab.
 after click "tail -f" , you can monitor the logs of that service.
 enjoy :)

please subscribe to my channel for linux related post : https://www.youtube.com/channel/UCIS1OSSZ9HBmI_KDY_PSPfQ?view_as=subscriber

Comments