https://www.jianshu.com/p/9abffc905645
1. 安装
宿主机环境:(Centos7)
宿主机环境
#yum install python-setuptools
yum install python-setuptools
#easy_install supervisor
easy_install supervisor
测试安装是否成功:
#echo_supervisord_conf
echo_supervisord_conf
2. 创建配置文件
创建 supervisor 配置文件目录 / 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
3. 调试
在 / 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
\================ 分割线 ================
这才是重点 ^^
- 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.log
- 每次修改配置文件后需进入 supervisorctl,执行 reload, 改动部分才能生效
reload
- 两个命令
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
关于进程监控及自动启动
Supervisor 学习
http://beginman.cn/linux/2015/04/06/Supervisor/
通过进程模型进行扩展