一、简介
- (1) 基于python编写,安装方便
- (2) 进程管理工具,可以很方便的对用户定义的进程进行启动,关闭,重启,并且对意外关闭的进程进行重启 ,只需要简单的配置一下即可,且有web端,状态、日志查看清晰明了。
- (3) 组成部分
supervisord
[服务端,要通过这个来启动它]supervisorctl
[客户端,可以来执行stop等命令]
- (4) 官方文档地址:http://supervisord.org/
二、安装及配置
(1)安装
# pip 安装
pip3 install supervisor
# yum 安装
yum install supervisor
# 源码安装
cd /usr/local/src
wget https://pypi.python.org/packages/7b/17/88adf8cb25f80e2bc0d18e094fcd7ab300632ea00b601cbbbb84c2419eae/supervisor-3.3.2.tar.gz
tar -zxvf supervisor-3.3.2.tar.gz
cd supervisor-3.3.2
python setup.py install # 本地python版本为python2.7
# python2.7 setup.py install
# 本地python版本为python3以上
# 目前superevisor还不支持python3.x版本
(2)配置
# 生成配置文件
echo_supervisord_conf > /etc/supervisord.conf
# 启动
supervisord -c /etc/supervisord.conf
查看supervisord
是否在运行:
ps aux |grep supervisord
三、使用说明
(1)查看默认配置
echo_supervisord_conf
输出如下:
; Sample supervisor config file.
;
; For more information on the config file, please see:
; http://supervisord.org/configuration.html
;
; Notes:
; - Shell expansion ("~" or "$HOME") is not supported. Environment
; variables can be expanded using this syntax: "%(ENV_HOME)s".
; - Quotes around values are not supported, except in the case of
; the environment= options as shown below.
; - Comments must have a leading space: "a=b ;comment" not "a=b;comment".
; - Command will be truncated if it looks like a config file comment, e.g.
; "command=bash -c 'foo ; bar'" will truncate to "command=bash -c 'foo ".
[unix_http_server]
file=/usr/local/var/run/supervisor.sock ; the path to the socket file
;chmod=0700 ; socket file mode (default 0700)
;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] ; inet (TCP) server disabled by default
;port=127.0.0.1:9001 ; ip_address:port specifier, *:port for all iface
;username=user ; default is no username (open server)
;password=123 ; default is no password (open server)
[supervisord]
logfile=/usr/local/var/log/supervisord.log ; main log file