Supervisor process monitors the installation and configuration of administrative tools on Mac

  • 2020-04-02 14:26:26
  • OfStack

(link: http://supervisord.org/) is a class under the Unix operating system, the process monitoring management tools.

The installation Supervisor

(link: http://supervisord.org/) is written by a Python, a Python package installation management tools are available (link: https://pypi.python.org/pypi/pip) installed directly:


sudo pip install supervisor

Configure the Supervisor

Supervisor's configuration file, named Supervisor ord.conf, provides configuration option Settings for Supervisor ord(Supervisor's master service command) and Supervisor orctl(Supervisor's supervisory management command). Supervisor does not specify the location of the configuration file Supervisor ord.conf, and the Supervisor service will start at:


$CWD/supervisord.conf
$CWD/etc/supervisord.conf
/etc/supervisord.conf

These directory locations look up the configuration file overord.conf. Supervisor also provides the parameter "-c" to specify the directory path for the configuration file.

Enter the "echo_supervisor _conf" command at the terminal to view the Supervisor's default configuration.

Generate a default profile:


echo_supervisord_conf > /etc/supervisord.conf

Here are some Settings selected, basically enough, the configuration 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 = 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 the Supervisor


supervisord -c /etc/supervisord.conf

The parameter "-c" indicates the path to specify the Supervisor configuration file

Add supervisory ord to the system startup service


<?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 Supervisor service:


launchctl load ~/Library/LaunchAgents/dengjoe.supervisord.plist

Monitor the monitor command

Supervisor is the Supervisor's own background process control tool. Here are some USES of this command:

Startup application:


supervisorctl start program

Re-read configuration:


supervisorctl update


Related articles: