https://www.cnblogs.com/xd502djj/p/13214174.html
supervisorctl有一个类型shell的命令行界面,我们可以利用它来查看子进程状态,启动/停止/重启子进程,获取running子进程的列表等等;Web Server主要可以在界面上管理进程,Web Server其实是通过XML_RPC来实现的,可以向supervisor请求数据,也可以控制supervisor及子进程。配置在[inet_http_server]块里面,XML_RPC接口是远程调用的,supervisorctl和Web Server就是它弄的。
1、RHEL6.5的python版本:
[root@DMS supervisor]# python
Python 2.6.6 (r266:84292, Sep 4 2013, 07:46:00)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2
2、安装supervisor-3.3.1-py2.6.egg时报错:提示
Installed /usr/lib/python2.6/site-packages/supervisor-3.3.1-py2.6.egg
Processing dependencies for supervisor==3.3.1
Searching for meld3>=0.6.5
Reading
Download error on : [Errno -2] Name or service not known -- Some packages may not be found!
Couldn't find index page for 'meld3' (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading
Download error on : [Errno -2] Name or service not known -- Some packages may not be found!
No local packages or working download links found for meld3>=0.6.5
error: Could not find suitable distribution for Requirement.parse('meld3>=0.6.5')
3、从
,解压python setup.py install安装。
4、下载安装setuptools-36.0.1.zip
5、 下载安装supervisor-3.3.1.tar.gz
6、配置文件:
1)创建/etc/ supervisor/conf.d文件夹
2)supervisord.conf放置于 /etc/ supervisor/下,其中
[include]
files = /etc/supervisor/conf.d/*.conf
3)所以将待监控进程以 .conf结尾的配置文件放置在 /etc/ supervisor/conf.d/目录下。
7、 supervisord.conf中
[supervisorctl]
serverurl =
username = root
password = 123456
prompt = mysupervisor
用户名密码设置不对的话,执行supervisorctl update报错:“Error:Server requires authentication”
8、 /etc/ supervisor/conf.d/目录下的配置文件例如adcc.conf[program:sendVer2Com1]
command = sudo xterm -e python sendVer2Com1.py ttyS1
//对于字符终端程序,要想启动独立的 xterm显示程序运行内容,需要使用“ xterm -e”,
//command只能是那种在终端运行的进程,不能是守护进程。比如说command=service httpd start。httpd这个进程被linux的service管理了,我们的supervisor再去启动这个命令
这已经不是严格意义的子进程了。
numprocs = 1
process_name=%(program_name)s-%(process_num)s
user = adcc
environment= HOME=/home/adcc
//设置程序运行时需要的环境变量,和别的子进程是不共享,如这里:家目录,
autostart=true
//如果是true的话,子进程将在supervisord启动后被自动启动默认就是true
autorestart=true
startretries=3 //默认3次
//当进程启动失败后,最大尝试启动的次数。。当超过3次后,supervisor将把此进程的状态置为FAIL
redirect_stderr = true
stopasgroup=true
killasgroup=true
directory = /home/adcc/monitor
stdout_logfile = /etc/supervisor/%(program_name)s.log
directory = /home/adcc/monitor/bin/ //进程运行前,会前切换到这个目录
//设置运行进程所在的目录,这样该进程使用相对路径找配置文件不会找不到。如:../resource/xxx.ini
来自 “ ITPUB博客 ” ,链接:
http://blog.itpub.net/7970627/viewspace-2702333/,如需转载,请注明出处,否则将追究法律责任。】