1.安裝
宿主機(jī)環(huán)境:(Centos7)
#yum install python-setuptools
#easy_install supervisor
測試安裝是否成功:
#echo_supervisord_conf
2.創(chuàng)建配置文件
創(chuàng)建supervisor配置文件目錄/etc/supervisor/?
#mkdir -m 755 -p /etc/supervisor/
創(chuàng)建主配文件supervisord.conf
#echo_supervisord_conf > /etc/supervisor/supervisord.conf
創(chuàng)建項(xiàng)目配置文件目錄
# mkdir -m 755 conf.d
3.調(diào)試
在/home/k1ic/supervisor_simple 目錄下創(chuàng)建test.c
編譯為test #gcc -o test test.c
在/etc/supervisor/conf.d 目錄下創(chuàng)建 test.ini
在主配文檔中引入test.ini
啟動(dòng)supervisor
# supervisord -c /etc/supervisor/supervisord.conf
查看supervisord.log發(fā)現(xiàn)program test已啟動(dòng)
# cat /tmp/supervisord.log
用 supervisorctl 查看已經(jīng)被監(jiān)控的program(注:直接用 #supervisorctl 會(huì)提示:http://localhost:9001 refused connection)
#supervisorctl -c /etc/supervisor/supervisord.conf
增加一例監(jiān)控php腳本
創(chuàng)建skud.ini
在/home/k1ic/supervisor_simple目錄下創(chuàng)建skuld.php
重啟監(jiān)控服務(wù)
================分割線================
這才是重點(diǎn)^^
0. supervisor 比較適合監(jiān)控業(yè)務(wù)應(yīng)用熏挎,且只能監(jiān)控前臺程序,php fork方式實(shí)現(xiàn)的daemon不能用它監(jiān)控,否則supervisor> status 會(huì)提示:BACKOFF? Exited too quickly (process log may have details)
1.每次修改配置文件后需進(jìn)入supervisorctl,執(zhí)行reload, 改動(dòng)部分才能生效
2.兩個(gè)命令
supervisord : supervisor的服務(wù)器端部分拴清,用于supervisor啟動(dòng)
supervisorctl:啟動(dòng)supervisor的命令行窗口,在該命令行中可執(zhí)行start、stop先誉、status、reload等操作的烁。
3.web管理界面
將supervisord.conf中[inet_http_server]部分做相應(yīng)配置褐耳,在supervisorctl中reload即可啟動(dòng)web管理界面
參考文獻(xiàn):
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錯(cuò)誤處理
http://beginman.cn/linux/2015/09/25/error-about-supervisord/
Supervisor監(jiān)控PHP進(jìn)程
http://www.phpddt.com/php/supervisor.html
關(guān)于進(jìn)程監(jiān)控及自動(dòng)啟動(dòng)
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學(xué)習(xí)
http://beginman.cn/linux/2015/04/06/Supervisor/
通過進(jìn)程模型進(jìn)行擴(kuò)展
http://12factor.net/zh_cn/concurrency