Supervisor process Daemons

Keywords: Python supervisor Linux Java

Explain

The company's Linux server is unable to connect to the Internet, so it can only download the installation package and upload it to the server for offline installation.

About Supervisor

Supervisor is a set of general process management program developed in Python, which can change a common command-line process into a background daemon, monitor the process status, and automatically restart when an exception exits. It uses fork/exec to start these managed processes as the sub processes of the supervisor, so as long as the path of the executable file of the process to be managed is written in the supervisor's configuration file. It also realizes that when the child process is hung up, the parent process can accurately obtain the information of the child process, and can choose whether to start and alarm itself. Supervisor also provides a function to set a non root user for supervisor or each subprocess, which can manage its corresponding processes.

Supervisor installation

  • Installing Python offline
-- Unzip the installation package
tar -zxvf Python-2.7.5.tgz

-- Enter the unzipped directory
cd Python-2.7.5

-- install python2.7.5 To the specified directory 
./configure –prefix=/usr/lib/python2.7/
make 
make install
 
-- Establish a soft connection
ln -s /usr/lib/python2.7/bin/python /bin/python
  • Install setuptools-2.0 offline
tar -xzvf setuptools-2.0.tar.gz 

cd setuptools-2.0 

python setup.py install
  • Install meld3-1.0.2 offline
tar zxvf meld3-1.0.2.tar.gz

cd meld3-1.0.2

python setup.py install
  • Install supervisor 3.1.3 offline
tar -zxvf supervisor-3.1.3.tar.gz

cd supervisor-3.1.3

python setup.py install

Supervisor configuration

  • Generate Supervisor profile
    echo_supervisord_conf > /etc/supervisord.conf
  • Start Supervisor
    supervisord -c /etc/supervisord.conf
  • Verify that the Supervisor starts
    ps aux | grep supervisord
  • Configure Supervisor application guard
-- stay etc Create application Guardian file storage directory and configuration file under directory
mkdir supervisor
cd supervisor
mkdir conf.d
cd conf.d

-- Configure Daemons
vi task.conf

[program:csxsettlement-framework-eureka]; apply name
user=root; Use root User execute start command
command=java -Xms256m -Xmx512m -jar /sxapp/sxappopt/csxs-settlement/framework/eureka/csxsettlement-framework-eureka.jar
directory=/sxapp/sxappopt/csxs-settlement/framework/eureka; jar Package directory
autostart = false; Auto start or not
autorestart = false; Whether to restart automatically
startsecs = 5
startretries = 3
redirect_stderr = true
stdout_logfile_maxbytes = 10MB
stdout_logfile_backups = 20
stdout_logfile =/sxapp/sxappopt/csxs-settlement/framework/eureka/stdout.log; Log directory and log file name
  • Modify the supervisor.conf file
-- open inet_http_server,Remove the front';'Number
[inet_http_server]         ; inet (TCP) server disabled by default
port=127.0.0.1:9001        ; (ip_address:port specifier, *:port for all iface)
username=user              ; (default is no username (open server))
password=123               ; (default is no password (open server))

-- Introducing configured Daemons
[include]
files = /etc/supervisor/conf.d/*.conf

Be careful:
After modifying the supervisor.conf configuration file, execute Supervisor - C / etc / supervisor.conf to restart the supervisor.

Supervisor management Daemons

  • Method 1: manage through the Supervisor's back management page

The account password is configured in the supervisor.conf file

Through the Supervisor management page, you can start, stop, restart and view the logs of the daemons.

  • Mode 2: manage through command in SSH console

Common related management commands

Supervisor CTL restart < application name >; restart the specified application
 Supervisor CTL stop < application name >; stop the specified application
 Supervisor CTL start < application name >; start the specified application
 Supervisor CTL restart all
 Supervisor CTL stop all
 Supervisor CTL start all;

Posted by binumathew on Sat, 26 Oct 2019 09:03:52 -0700