Centos7.x installation Supervisord

 

 

【surroundings】

Systems: Centos 7.3

Software: supervisord

 

[Installation] Supervisord

yum install epel-release
yum install -y supervisor

[Settings] to open from the start

systemctl enable supervisord

[Supervisord management commands]

systemctl stop supervisord
systemctl start supervisord
systemctl status supervisord
systemctl reload supervisord
systemctl restart supervisord

[Modify the configuration file, the web may be displayed so that the end Supervisord]

vim /etc/supervisord.conf

# Cancel 10- 13 rows comment, before the number is the row number
 10 [inet_http_server]; inet (the TCP) Server Disabled by default
 . 11 Port = 127.0.0.1 : 9001         ; (ip_address: Port specifier, *: Port for All iface)
 12 is username = User; (IS NO default username (Open Server))
 13 is password = 123                ; (IS NO default password (Open Server))

【monitor】

Then set up monitoring files and scripts, etc.

For example, we create a cycle of death, let the script to monitor, here take it for python

Create a while loop py file in your home directory

vim /home/test.py

while True:

   print(100)

This document has been printed 100 without forcing the termination will not stop, the next configuration supervisord. We can see by the last line of the configuration file

cat /etc/supervisord.conf

[include]
files = supervisord.d / * .ini

In other words, all of our configuration files are stored in this directory to .ini format named saved, you can change the address on their own, but do not modify the suffix, then we file it creates supervisor

[File] create Supervisord

vim /etc/supervisord.d/python.ini

[Program: python] # python here is that we monitor displays the name of the web front-end and terminal
the Command = Python / Home / test.py # file address we want to monitor
autostart = to true 
autorestart is = to true 
startsecs = . 1 
startretries = . 3 
redirect_stderr is = to true 
stdout_logfile = / etc / supervisord.log / access_python.log # log address, the directory may be configured to self
stderr_logfile = / etc / supervisord.log / log # error_python.log address, the directory may be configured to self

[Start] Supervisord

systemctl start supervisord
Check whether to activate
systemctl status supervisord

Note: If you can not start after a successful landing web terminal, port 9001 is allowed through the firewall or turn off the firewall, turn off selinux, the supervisord.conf the port = 127.0.0.1: 9001 in the IP address 127.0.0.1 modified to restart the service access

[Web] end landing

 

 【Landed successfully】

 

 

After landing, will appear the following interface, you can do some action with the file open, stop, view the log, clear the log

 

Guess you like

Origin www.cnblogs.com/willamwang/p/11447404.html