supervisor安装
方法一
1:用管理员安装python-setuptools
suse
zypper in python-setuptools
centos
yum install python-setuptools
2:安装superviso
easy_install superviso
方法二:
wget https://pypi.python.org/packages/source/s/supervisor/supervisor-3.1.3.tar.gz --no-check-certificat
tar -xvf meld3-0.6.10.tar.gz
cd meld3-0.6.10/
python setup.py install
tar -xvf supervisor-3.1.3.tar.gz
cd supervisor-3.1.3/
python setup.py install
#此过程没有外网权限的话会安装失败 需要一些依赖包,最好一次性先安装好相关包 生产环境依赖 meld3-0.6.10.tar.gz 版本要大于0.6.5 下载地址https://pypi.python.org/simple/meld3/
检查:导入成功说明安装OK
import supervisor
或者执行:显示出配置文件信息说明安装成功
echo_supervisord_conf
配置文件
echo_supervisord_conf > /etc/supervisord.conf
demo
=========================================================================================================
[unix_http_server]
file=/tmp/supervisor.sock ; (the path to the socket file)
[supervisord]
logfile=/tmp/supervisord.log ; (main log file;default $CWD/supervisord.log)
logfile_maxbytes=50MB ; (max main logfile bytes b4 rotation;default 50MB)
logfile_backups=10 ; (num of main logfile rotation backups;default 10)
loglevel=info ; (log level;default info; others: debug,warn,trace)
pidfile=/tmp/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
nodaemon=false ; (start in foreground if true;default false)
minfds=1024 ; (min. avail startup file descriptors;default 1024)
minprocs=200 ; (min. avail process descriptors;default 200)
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[supervisorctl]
serverurl=unix:///tmp/supervisor.sock ; use a unix:// URL for a unix socket
[program:openvpn]
command=/opt/huawei/openvpn/sbin/openvpn --config /opt/huawei/openvpn/server.conf
autostart=true
autorestart=true
startsecs=5
startretries=3
redirect_stderr = true
stdout_logfile=/tmp/openvpn_supervisor.log
stdout_logfile_maxbytes = 20MB
stdout_logfile_backups = 5
stopasgroup=true
killasgroup=true
=========================================================================================================
配置(以下在生产环境没有测试成功,google看了很多相关文章也未解决,怀疑跟权限有关)
使用root身份创建一个全局配置文件echo_supervisord_conf > /etc/supervisord.conf,supervisord程序在运行后会自动查找并加载此目录配置文件。
若不用root 你要按照下面的方法生成配置文件 一下是官方的原文
Creating a Configuration File
Once the Supervisor installation has completed, run echo_supervisord_conf. This will print a “sample” Supervisor configuration file to your terminal’s stdout.
Once you see the file echoed to your terminal, reinvoke the command as echo_supervisord_conf > /etc/supervisord.conf. This won’t work if you do not have root access.
If you don’t have root access, or you’d rather not put the supervisord.conf file in /etc/supervisord.conf`, you can place it in the current directory (echo_supervisord_conf > supervisord.conf) and start supervisord with the -c flag in order to specify the configuration file location.
启动
supervisord -c /etc/supervisord.conf
supervisorctl 命令管里
upervisord,初始启动Supervisord,启动、管理配置中设置的进程。
sudo supervisorctl status 查看素有spawn进程的状态
supervisorctl stop programxxx,停止某一个进程(programxxx),programxxx为[program:chatdemon]里配置的值,这个示例就是chatdemon。
supervisorctl start programxxx,启动某个进程
supervisorctl restart programxxx,重启某个进程
supervisorctl stop groupworker: ,重启所有属于名为groupworker这个分组的进程(start,restart同理)
supervisorctl stop all,停止全部进程,注:start、restart、stop都不会载入最新的配置文件。
supervisorctl reload,载入最新的配置文件,停止原有进程并按新的配置启动、管理所有进程。
supervisorctl update,根据最新的配置文件,启动新配置或有改动的进程,配置没有改动的进程不会受影响而重启
注意:显示用stop停止掉的进程,用reload或者update都不会自动重启。