supervisor安装文档
######################
安装需求:python2.7以上版本
python2.6升级:
1、下载Python-2.7.15
wget http://python.org/ftp/python/2.7.15/Python-2.7.15.tar.bz2
2、解压
tar -jxvf Python-2.7.15.tar.bz2
3、
cd Python-2.7.3
#./configure --prefix=/usr/local/python2.7
#make
#make install
###注意:安装时先安装 zlib zlib-devel
4、建立软连接,使系统默认的 python指向 python2.7
#mv /usr/bin/python /usr/bin/python2.6.6
#ln -s /usr/local/bin/python2.7 /usr/bin/python
5、修改yum
vi /usr/bin/yum
将文件头部的
#!/usr/bin/python
改成
#!/usr/bin/python2.6
###################
安装python pkg 包:distribute-0.6.10.zip (python2.7)
#unzip distribute-0.6.10.zip
#python setup.py install
安装: supervisor
#yum install python-setuptools
#/usr/local/python2.7/bin/easy_install supervisor
默认安装 /usr/local/python2.7/bin 目录下:
supervisord 、echo_supervisord_conf、supervisorctl
生成配置文件:
#./echo_supervisord_conf > supervisord.conf
配置文件如下:
[tomcat@footballweb supervisor]$ cat supervisord.conf |grep -v ^;
[unix_http_server]
file=/tmp/supervisor.sock ; the path to the socket file
[inet_http_server] ; inet (TCP) server disabled by default
port=0.0.0.0:39001 ; ip_address:port specifier, *:port for all iface 页面管理地址
username=huitou ; default is no username (open server) --登陆用户名/密码
password=huitou&365 ; default is no password (open server)
[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 ; # of main logfile backups; 0 means none, 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
prompt=mysupervisor ; cmd line prompt (default "supervisor")
history_file=~/.sc_history ; use readline history if available
[program:tomcat_8081]
command=/opt/apache-tomcat-7.0.81_8081/bin/catalina.sh run ; 程序启动命令
environment=JAVA_HOME="/usr/java/jdk1.7.0_71",JAVA_BIN="/usr/java/jdk1.7.0_71/bin",LANG="zh_CN.GB18030" ;
directory=/opt/apache-tomcat-7.0.81_8081 ;
autostart=true ; 在supervisord启动的时候也自动启动
startsecs=20 ; 启动10秒后没有异常退出,就表示进程正常启动了,默认为1秒
autorestart=true ; 程序退出后自动重启,[unexpected,true,false],默认为unexpected,表示进程意外杀死后才重启
startretries=3 ; 启动失败自动重试次数,默认是3
user=tomcat ; 用哪个用户启动进程,默认是root
priority=999 ; 进程启动优先级,默认999,值小的优先启动
redirect_stderr=true ; 把stderr重定向到stdout,默认false
stdout_logfile_maxbytes=20MB ; stdout 日志文件大小,默认50MB
stdout_logfile_backups = 20 ; stdout 日志文件备份数,默认是10
stdout_logfile=/opt/apache-tomcat-7.0.81_8081/logs/supervisor_catalina.out ;
stopasgroup=true ;默认为false,进程被杀死时,是否向这个进程组发送stop信号,包括子进程
killasgroup=true ;默认为false,向进程组发送kill信号,包括子进程
supervisor启动:
#./supervisord -c ./supervisord.conf