Supervisor is a process monitoring management tool under a UNIX-like operating system.
Installing Supervisor
Supervisor is written by Python and can be installed directly using Python's Package Installation management tool PIP (Python pack Index):
Copy the Code code as follows:
sudo pip install Supervisor
Configure Supervisor
The configuration file for Supervisor is named Supervisord.conf, which provides configuration option settings for Supervisord (Supervisor's Primary service command) and Supervisorctl (Supervisor's monitoring Management command). Supervisor does not specify the location of the configuration file supervisord.conf, the Supervisor service starts by default when:
Copy the Code code as follows:
$CWD/supervisord.conf
$CWD/etc/supervisord.conf
/etc/supervisord.conf
These directory locations find the configuration file supervisord.conf. Supervisor also provides the parameter "-C" to specify the directory path of the configuration file.
Enter the "echo_supervisord_conf" command at the terminal to view the contents of the Supervisor default configuration.
Generate a copy of the default configuration file:
Copy the Code code as follows:
echo_supervisord_conf >/etc/supervisord.conf
Here are the options to set up some configuration, basic enough, configured as follows:
Copy the Code code as follows:
[Inet_http_server]
Port = 127.0.0.1:9001
Username = DHQ
Password = 123456
[Unix_http_server]
File =/tmp/supervisor.sock
chmod = 0700
[Supervisord]
LogFile =/users/dengjoe/.supervisor/supervisord.log
Logfile_maxbytes = 50MB
logfile_backups=10
LogLevel = info
Pidfile =/tmp/supervisord.pid
Nodaemon = False
Minfds = 1024
Minprocs = 200
Umask = 022
Identifier = Supervisor
Directory =/tmp
Nocleanup = True
Childlogdir =/tmp
[Supervisorctl]
ServerURL = Unix:///tmp/supervisor.sock
[Rpcinterface:supervisor]
Supervisor.rpcinterface_factory = Supervisor.rpcinterface:make_main_rpcinterface
[Program:shadowsocks]
Directory =/users/dengjoe/shadowsocks
Command =/usr/bin/python/users/dengjoe/shadowsocks/local.py
Autostart = True
AutoRestart = True
Start Supervisor
Copy the Code code as follows:
Supervisord-c/etc/supervisord.conf
The parameter "-C" indicates the path to the specified Supervisor configuration file
Adding Supervisord to the system startup service
Copy the Code code as follows:
<?xml version= "1.0" encoding= "UTF-8"?>
KeepAlive
Successfulexit
Label
Dengjoe.supervisord
Programarguments
/usr/local/bin/supervisord
-N
-C
/etc/supervisord.conf
Runatload
To start the Supervisor service:
Copy the Code code as follows:
Launchctl Load ~/library/launchagents/dengjoe.supervisord.plist
Supervisorctl Monitoring Commands
Supervisorctl is Supervisor's own background Process Control tool, here are some uses of the command:
To launch an app:
Copy the Code code as follows:
Supervisorctl Start Program
To re-read the configuration:
Copy the Code code as follows:
SUPERVISORCTL Update