Install and configure the Supervisor process monitoring management tool on Mac
Supervisor is a process monitoring and management tool in unix-like operating systems.
Install Supervisor
The Supervisor is written in Python and can be directly installed using the Python Package installation management tool pip (Python Package Index:
Copy codeThe Code is as follows:
Sudo pip install supervisor
Configure a Supervisor
The configuration file of the Supervisor is named supervisord. conf, which provides configuration option settings for supervisord (the main service command of the Supervisor) and supervisorctl (the Monitoring and Management command of the Supervisor. The Supervisor does not specify the storage location of the configuration file supervisord. conf. By default, when the Supervisor service is started:
Copy codeThe Code is as follows:
$ CWD/supervisord. conf
$ CWD/etc/supervisord. conf
/Etc/supervisord. conf
Find the configuration file supervisord. conf in these directories. The Supervisor also provides the "-c" parameter to specify the directory path of the configuration file.
Enter the "echo_supervisord_conf" command on the terminal to view the default configurations of the Supervisor.
Generate a default configuration file:
Copy codeThe Code is as follows:
Echo_supervisord_conf>/etc/supervisord. conf
Some configurations are selected here, which are adequate. The configuration is as follows:
Copy codeThe Code is 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 = 50 MB
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 codeThe Code is as follows:
Supervisord-c/etc/supervisord. conf
The "-c" parameter specifies the path of the Supervisor configuration file.
Add supervisord to the system startup Service
Copy codeThe Code is as follows:
<? Xml version = "1.0" encoding = "UTF-8"?>
<! DOCTYPE plist PUBLIC "-// Apple // dtd plist 1.0 // EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<Plist version = "1.0">
<Dict>
<Key> KeepAlive </key>
<Dict>
<Key> SuccessfulExit </key>
<False/>
</Dict>
<Key> Label </key>
<String> dengjoe. supervisord </string>
<Key> ProgramArguments </key>
<Array>
<String>/usr/local/bin/supervisord </string>
<String>-n </string>
<String>-c </string>
<String>/etc/supervisord. conf </string>
</Array>
<Key> RunAtLoad </key>
<True/>
</Dict>
</Plist>
Start the Supervisor service:
Copy codeThe Code is as follows:
Launchctl load ~ /Library/LaunchAgents/dengjoe. supervisord. plist
Supervisorctl monitoring command
Supervisorctl is a background process control tool provided by the Supervisor. The following describes how to use this command:
Start the application:
Copy codeThe Code is as follows:
Supervisorctl start program
Re-read Configuration:
Copy codeThe Code is as follows:
Supervisorctl update