首頁 > 軟體

類Unix 作業系統進程監控控制工具 Supervisor

2020-06-16 17:43:42

Supervisor 是一個用戶端伺服器系統,允許使用者監控和控制類 Unix 作業系統上的進程數。

官網 http://supervisord.org

安裝
1. easy_install supervisor
2.
setuptools (latest) from http://pypi.Python.org/pypi/setuptools.
meld3 (latest) from http://www.plope.com/software/meld3/.
elementtree (latest) from http://effbot.org/downloads#elementtree.

建立組態檔
echo_supervisord_conf > /etc/supervisord.conf
指定組態檔
supervisord -c supervisord.conf

查詢組態檔路經
-c 指定組態檔
無指定組態檔時,查詢順序:
1 $CWD/supervisord.conf
2 $CWD/etc/supervisord.conf
3 /etc/supervisord.conf

組態檔說明

HTTP/XML-RPC 相關設定
[unix_http_server]
file = /tmp/supervisor.sock
chmod = 0777
chown= nobody:nogroup
username = user
password = 123

Web管理介面設定
[inet_http_server]
port = 127.0.0.1:9001
username = user
password = 123

[supervisorctl]
serverurl = unix:///tmp/supervisor.sock 和[unix_http_server]匹配
username = chris
password = 123
prompt = mysupervisor

紀錄檔 環境等設定
[supervisord]
logfile = /tmp/supervisord.log
logfile_maxbytes = 50MB
logfile_backups=10
loglevel = info
pidfile = /tmp/supervisord.pid
nodaemon = false
minfds = 1024
minprocs = 200
umask = 022
user = chrism
identifier = supervisor
directory = /tmp
nocleanup = true
childlogdir = /tmp
strip_ansi = false
environment = KEY1="value1",KEY2="value2"

設定單個進程
[program:theprogramname]
command=/bin/cat ; the program (relative uses PATH, can take args)
process_name=%(program_name)s ; process_name expr (default %(program_name)s)
numprocs=1 ; number of processes copies to start (def 1)
directory=/tmp ; directory to cwd to before exec (def no cwd)
umask=022 ; umask for process (default None)
priority=999 ; the relative start priority (default 999)
autostart=true ; start at supervisord start (default: true)
autorestart=unexpected ; whether/when to restart (default: unexpected)
startsecs=1 ; number of secs prog must stay running (def. 1)
startretries=3 ; max # of serial start failures (default 3)
exitcodes=0,2 ; 'expected' exit codes for process (default 0,2)
stopsignal=QUIT ; signal used to kill process (default TERM)
stopwaitsecs=10 ; max num secs to wait b4 SIGKILL (default 10)
stopasgroup=false ; send stop signal to the UNIX process group (default false)
killasgroup=false ; SIGKILL the UNIX process group (def false)
user=chrism ; setuid to this UNIX account to run the program
redirect_stderr=true ; redirect proc stderr to stdout (default false)
stdout_logfile=/a/path ; stdout log path, NONE for none; default AUTO
stdout_logfile_maxbytes=1MB ; max # logfile bytes b4 rotation (default 50MB)
stdout_logfile_backups=10 ; # of stdout logfile backups (default 10)
stdout_capture_maxbytes=1MB ; number of bytes in 'capturemode' (default 0)
stdout_events_enabled=false ; emit events on stdout writes (default false)
stderr_logfile=/a/path ; stderr log path, NONE for none; default AUTO
stderr_logfile_maxbytes=1MB ; max # logfile bytes b4 rotation (default 50MB)
stderr_logfile_backups=10 ; # of stderr logfile backups (default 10)
stderr_capture_maxbytes=1MB ; number of bytes in 'capturemode' (default 0)
stderr_events_enabled=false ; emit events on stderr writes (default false)
environment=A="1",B="2" ; process environment additions (def no adds)
serverurl=AUTO ; override serverurl computation (childutils)

另外設定還有
[fcgi-program:x]

[eventlistener:x]

[rpcinterface:x]

包含指定的組態檔
[include]
files = /an/absolute/filename.conf /an/absolute/*.conf foo.conf config??.conf

本文永久更新連結地址http://www.linuxidc.com/Linux/2016-04/130162.htm


IT145.com E-mail:sddin#qq.com