supervisor 文檔

supervisor 是用 Python 開發的一個 C/S 服務。是 Linux/Unix 系統下的進程管理工具。它能夠很方便的監聽、啓動、中止、重啓一個或多個進程。用Supervisor管理的進程,當一個進程意外被殺死,supervisort監聽到進程死後,會自動將它從新拉起,很方便的作到進程自動恢復的功能,再也不須要本身寫shell腳原本控制。web

安裝

pip 方式shell

pip install supervisor

yum 方式apache

wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum install supervisor -y

配置文件

pip 安裝的需自行生成配置文件tomcat

echo_supervisord_conf > /etc/supervisord.conf

cat /etc/supervisord.confsocket

[unix_http_server]
file=/opt/supervisor.sock   ; supervisorctl 使用的 socket 文件
chmod=0700                 ; socket 文件權限
;chown=nobody:nogroup       ; socket file uid:gid owner
;username=user              ; default is no username (open server)
;password=123               ; default is no password (open server)

[inet_http_server]         ; web 管理界面,即在頁面作重啓、中止等操做
port=*:9001                ; 監聽端口
username=admin             ; 用戶
password=123               ; 密碼

[supervisord]
logfile=/var/log/supervisord.log ; supervisor日誌文件 $CWD/supervisord.log
logfile_maxbytes=50MB        ; 日誌文件大小,默認 50MB
logfile_backups=1           ; 默認保留1個文件
loglevel=info                ; 日誌級別,默認info; 其餘格式: debug,warn,trace
pidfile=/var/run/supervisord.pid ; pid 文件
nodaemon=false               ; 是否在前臺運行,默認false,以 daemon模式運行
minfds=1024                  ; 能夠打開文件描述符的最小值
minprocs=200                 ; 能夠打開進程數最小值
;umask=022                   ; process file creation umask; default 022
;user=chrism                 ; default is current user, required if root
;identifier=supervisor       ; supervisord identifier, default is 'supervisor'
;directory=/opt              ; default is not to cd during start
;nocleanup=true              ; don't clean up tempfiles at start; default false
;childlogdir=/opt            ; 'AUTO' child log dir, default $TEMP
;environment=KEY="value"     ; key value pairs to add to environment
;strip_ansi=false            ; strip ansi escape codes in logs; def. false


[supervisorctl]
serverurl=unix:///opt/supervisor.sock ; use a unix:// URL  for a unix socket
;serverurl=http://127.0.0.1:9001 ; use an http:// url to specify an inet socket
;username=chris              ; should be same as in [*_http_server] if set
;password=123                ; should be same as in [*_http_server] if set
;prompt=mysupervisor         ; cmd line prompt (default "supervisor")
;history_file=~/.sc_history  ; use readline history if available


[include]
files = /etc/supervisord.d/*.conf ;子文件

管理tomcat配置文件ide

cat /etc/supervisord.d/cms.conf工具

[program:cms]
command=/home/work/tomcat/cms-102/apache-tomcat-7.0.88/bin/catalina.sh run
environment=JAVA_HOME="/usr/local/jdk/",JAVA_BIN="/usr/local/jdk/bin"
stdout_logfile=/home/work/tomcat/cms-102/apache-tomcat-7.0.88/logs/catalina.out
autostart=true
autorestart=true
startsecs=5
priority=1
stopasgroup=true
killasgroup=true

執行ui

# supervisord -c /etc/supervisord.conf
# supervisorctl 
cms                              RUNNING   pid 12328, uptime 5:59:22
free-wifi                        RUNNING   pid 10534, uptime 6:31:34
government-services              RUNNING   pid 10475, uptime 6:31:34
idcard                           RUNNING   pid 13469, uptime 4:01:20

# supervisorctl restart cms
# supervisorctl start cms
# supervisorctl stop cms
相關文章
相關標籤/搜索