1.安装
宿主机环境:(Centos7)
宿主机环境#yum install python-setuptools
yum install python-setuptools#easy_install supervisor
easy_install supervisor测试安装是否成功:
#echo_supervisord_conf
echo_supervisord_conf2.创建配置文件
创建supervisor配置文件目录/etc/supervisor/
#mkdir -m 755 -p /etc/supervisor/
mkdir -m 755 -p /etc/supervisor/创建主配文件supervisord.conf
#echo_supervisord_conf > /etc/supervisor/supervisord.conf
echo_supervisord_conf > /etc/supervisor/supervisord.conf创建项目配置文件目录
# mkdir -m 755 conf.d
# mkdir -m 755 conf.d3.调试
在/home/k1ic/supervisor_simple 目录下创建test.c
test.c编译为test #gcc -o test test.c
gcc -o test test.c在/etc/supervisor/conf.d 目录下创建 test.ini
test.ini在主配文档中引入test.ini
files = ./conf.d/*.ini启动supervisor
# supervisord -c /etc/supervisor/supervisord.conf
supervisord -c /etc/supervisor/supervisord.conf pstree -p | grep supervisord查看supervisord.log发现program test已启动
# cat /tmp/supervisord.log
# cat /tmp/supervisord.log用 supervisorctl 查看已经被监控的program(注:直接用 #supervisorctl 会提示:http://localhost:9001 refused connection)
#supervisorctl -c /etc/supervisor/supervisord.conf
supervisorctl -c /etc/supervisor/supervisord.conf增加一例监控php脚本
创建skud.ini
skud.ini [program:skuld]在/home/k1ic/supervisor_simple目录下创建skuld.php
skuld.php重启监控服务
reload pstree================分割线================
这才是重点^^
0. supervisor 比较适合监控业务应用,且只能监控前台程序,php fork方式实现的daemon不能用它监控,否则supervisor> status 会提示:BACKOFF Exited too quickly (process log may have details)
BACKOFF Exited too quickly (process log may have details) cat supervisord.log1.每次修改配置文件后需进入supervisorctl,执行reload, 改动部分才能生效
reload2.两个命令
supervisord : supervisor的服务器端部分,用于supervisor启动
supervisorctl:启动supervisor的命令行窗口,在该命令行中可执行start、stop、status、reload等操作。
3.web管理界面
将supervisord.conf中[inet_http_server]部分做相应配置,在supervisorctl中reload即可启动web管理界面
[inet_http_server] http://107.170.249.52:9001/?message=Page%20refreshed%20at%20Tue%20Sep%2029%2016%3A20%3A40%202015参考文献:
Supervisor的安装与使用入门
http://fukun.org/archives/07102224.html
按需讲解之Supervisor
http://www.cnblogs.com/yjf512/archive/2012/03/05/2380496.html
supervisord entered FATAL state, too many start retries too quickly错误处理
http://beginman.cn/linux/2015/09/25/error-about-supervisord/
Supervisor监控PHP进程
http://www.phpddt.com/php/supervisor.html
关于进程监控及自动启动
http://www.vimer.cn/2013/07/%E5%85%B3%E4%BA%8E%E8%BF%9B%E7%A8%8B%E7%9B%91%E6%8E%A7%E5%8F%8A%E8%87%AA%E5%8A%A8%E5%90%AF%E5%8A%A8.html
Supervisor学习
http://beginman.cn/linux/2015/04/06/Supervisor/
通过进程模型进行扩展
http://12factor.net/zh_cn/concurrency
网友评论