首页 技术 正文
技术 2022年11月6日
0 收藏 754 点赞 705 浏览 2110 个字

Supervisor是一个进程监控程序。

满足的需求是:我现在有一个进程需要每时每刻不断的跑,但是这个进程又有可能由于各种原因有可能中断。当进程中断的时候我希望能自动重新启动它,此时,我就需要使用到了Supervisor.

先弄懂两个命令:

supervisord : supervisor的服务器端部分,启动supervisor就是运行这个命令

supervisorctl:启动supervisor的命令行窗口

安装(Centos):

[root@iZ94xdyrdjmZ etc]# yum install python-setuptools

[root@iZ94xdyrdjmZ etc]# easy_install supervisor

测试是否安装成功

[root@iZ94xdyrdjmZ etc]# echo_supervisord_conf

会显示以下内容,其实是一个配置模版:

创建配置文件

[root@iZ94xdyrdjmZ etc]# echo_supervisord_conf > /etc/supervisord.conf

修改配置文件

在supervisord.conf最后增加(分号后边的表示注释,可以不写):

[include] 
files = /etc/subversion/*.ini

在 /etc/subversion/ 目录下建立 swoole-crontab.ini 文件

[program:swoole-crontab]
command=php /alidata/www/didi365/Crontab/main.php -d -s start
autorstart=true
autorestart=true
stdout_logfile=/tmp/supervisor.log

[Web配置]
[inet_http_server] ; inet (TCP) server disabled by default
port=*: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))
如果配置了用户名和密码,就需要输入用户名和密码才能进入web界面

[启动supervisord]

[root@iZ94xdyrdjmZ etc]# supervisord

可能会输出一堆信息出来
/usr/lib/python2.6/site-packages/supervisor-3.1.3-py2.6.egg/supervisor/options.py:296: UserWarning: Supervisord is running as root and it is searching for its configuration file in default locations (including its current working directory); you probably want to specify a “-c” argument specifying an absolute path to a configuration file for improved security.
‘Supervisord is running as root and it is searching ‘
/usr/lib/python2.6/site-packages/supervisor-3.1.3-py2.6.egg/supervisor/options.py:383: DeprecationWarning: Parameters to load are deprecated. Call .resolve and .require separately.
return pkg_resources.EntryPoint.parse(“x=”+spec).load(False)
不用管它

[root@iZ94xdyrdjmZ etc]# ps -ef | grep supervis

root 450 9437 0 11:31 pts/0 00:00:00 grep supervis
root 18836 1 0 10:02 ? 00:00:01 /usr/bin/python /usr/bin/supervisord

[命令行管理工具]

[root@iZ94xdyrdjmZ etc]# supervisorctl status

swoole-crontab                   RUNNING   pid 29981, uptime 0:33:05

如果修改了 /etc/supervisord.conf ,需要执行 supervisorctl reload 来重新加载配置文件

Error: Another program is already listening on a port that one of our HTTP servers is configured to use. Shut this program down first before starting

解决方法:

find / -name supervisor.sock

unlink /name/supervisor.sock

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,487
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,903
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,736
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,487
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:8,127
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:5,289