SlideShare una empresa de Scribd logo
1 de 5
Descargar para leer sin conexión
使用 Supervisor 守护 Python 进程
Author:guosong@staff.sina.com.cn
1、需求
现在有一个进程需要每时每刻不断的跑,但是这个进程又有可能由于各种原因有可能中断。当进
程中断的时候我希望能自动重新启动它,此时,就需要使用到了 Supervisor。Supervisor 起
到守护进程的作用。
2、安装
https://pypi.python.org/pypi/supervisor
tar zxvf supervisor-3.0.tar.gz
cd supervisor-3.0
python2.7 setup.py build
python2.7 setup.py install
需要依赖于 meld3-1.0.0.tar.gz,联网安装,由于所在机器无法上网,故进行手动安装 meld。
参照上面方法再进行安装 meld,安装完成之后再次进行 install 即可。
测试安装是否成功:echo_supervisord_conf
配置文件:echo_supervisord_conf > /etc/supervisord.conf
3、Supervisor 相关
supervisord : supervisor 的服务器端部分,启动 supervisor 就是运行这个命令
supervisorctl:启动 supervisor 的命令行窗口
4、Demo1 测试
需求是对本地的 API 进程进行守护,要求这个服务能在意外停止后自动重启。
API 的执行命令为:python2.6 /data1/guosong/mysqlapi/main/api_main.py
--port=8005
修改配置文件:
[program:mysqlapi]
command = python2.6 /data1/guosong/mysqlapi/main/api_main.py --port=8005
autostart = true
autorestart = true
startsecs = 3
stdout_logfile = /data1/guosong/mysqlapi/log/mysqlapi_demo1.log
启动 supervisord:
[root@typhoeus79 mysqlapi]# ps aux |grep super
root 15377 0.0 0.0 61268 788 pts/3 R+ 16:23 0:00 grep super
[root@typhoeus79 mysqlapi]# supervisord
Unlinking stale socket /var/tmp/supervisor.sock
[root@typhoeus79 mysqlapi]# ps aux |grep super
root 15458 0.0 0.0 147148 7976 ? Ss 16:23 0:00 /usr/bin/python
/usr/bin/supervisord
root 15533 0.0 0.0 61268 792 pts/3 S+ 16:23 0:00 grep super
查看进程状态:
[root@typhoeus79 mysqlapi]# supervisorctl
mysqlapi RUNNING pid 15460, uptime 0:01:19
supervisor> status
mysqlapi RUNNING pid 15460, uptime 0:01:21
supervisor> exit
[root@typhoeus79 mysqlapi]# ps aux |grep 8005
root 15460 0.2 0.0 208436 15484 ? S 16:23 0:00 python2.6
/data1/guosong/mysqlapi/main/api_main.py --port=8005
root 16314 0.0 0.0 61268 788 pts/3 S+ 16:24 0:00 grep 8005
[root@typhoeus79 mysqlapi]#
kill 测试:
[root@typhoeus79 mysqlapi]# ps aux |grep 8005
root 15460 0.2 0.0 208436 15484 ? S 16:23 0:00 python2.6
/data1/guosong/mysqlapi/main/api_main.py --port=8005
root 16314 0.0 0.0 61268 788 pts/3 S+ 16:24 0:00 grep 8005
[root@typhoeus79 mysqlapi]#
[root@typhoeus79 mysqlapi]# kill 15460
[root@typhoeus79 mysqlapi]# ps aux |grep 8005
root 17431 21.0 0.0 208436 15484 ? S 16:25 0:00 python2.6
/data1/guosong/mysqlapi/main/api_main.py --port=8005
root 17437 0.0 0.0 61268 772 pts/3 R+ 16:25 0:00 grep 8005
[root@typhoeus79 mysqlapi]# kill -9 17431
[root@typhoeus79 mysqlapi]# ps aux |grep 8005 |grep -v grep
root 17540 7.0 0.0 208440 15488 ? S 16:25 0:00 python2.6
/data1/guosong/mysqlapi/main/api_main.py --port=8005
[root@typhoeus79 mysqlapi]#
使用 kill 以及 kill -9 进程的 id 都发生变化
使用 supervisorctl 进行程序重启:
[root@typhoeus79 mysqlapi]# supervisorctl stop all
mysqlapi: stopped
[root@typhoeus79 mysqlapi]# ps aux |grep 8005 |grep -v grep
[root@typhoeus79 mysqlapi]# supervisorctl start all
mysqlapi: started
[root@typhoeus79 mysqlapi]# ps aux |grep 8005 |grep -v grep
root 19649 3.0 0.0 208440 15488 ? S 16:28 0:00 python2.6
/data1/guosong/mysqlapi/main/api_main.py --port=8005
[root@typhoeus79 mysqlapi]#
5、Demo2 测试
守护多个进程,修改/etc/supervisord.conf 配置
[program:mysqlapi]
command=python26 /data1/guosong/mysqlapi/main/api_main.py
--port=140%(process_num)02d
process_name=%(program_name)s_%(process_num)02d ; process_name expr
(default %(program_name)s)
numprocs=8
numprocs_start=81
startretries=3
stopwaitsecs=10
autorstart=true
log_stdout=true
log_stderr=true
logfile=/data1/guosong/mysqlapi/log/mysql_api_demo.log
超过 2 位数如何表示?
command=python26 /data1/guosong/mysqlapi/main/api_main.py
--port=140%(process_num)02d
结果演示:
6、问题集锦
问题 1-mysqlapi entered FATAL state, too many start retries too quickly:
2014-05-15 17:26:30,898 INFO exited: mysqlapi (exit status 1; not expected)
2014-05-15 17:26:30,899 INFO received SIGCLD indicating a child quit
2014-05-15 17:26:31,901 INFO gave up: mysqlapi entered FATAL state, too many
start retries too quickly
原因在于版本导致,api 的脚本版本为 python26,故使用 supervisord 也需要使用 python26
进行安装,查看进程信息如下:
root 24058 0.0 0.0 151420 10204 ? Ss 18:28 0:00
/usr/bin/python26 /usr/bin/supervisord -c /etc/supervisord.conf
问题 2- http://127.0.0.1:9001 refused connection:
[root@typhoeus79 20140515]# supervisorctl
http://10.75.xxx.xxx:9001 refused connection
原因在于没有开启 inet_http_server,配置文件默认使用分号注释每行
将 inet_http_server 前面的分号去除后,重新开启 supervisord
[root@typhoeus79 20140515]# /etc/init.d/supervisord stop
Stopping supervisord: [ OK ]
[root@typhoeus79 20140515]# supervisord -c /etc/supervisord.conf
[root@typhoeus79 20140515]# supervisorctl
mysqlapi:mysqlapi_81 RUNNING pid 32513, uptime 0:00:02
mysqlapi:mysqlapi_82 RUNNING pid 32511, uptime 0:00:02
mysqlapi:mysqlapi_83 RUNNING pid 32512, uptime 0:00:02
mysqlapi:mysqlapi_84 RUNNING pid 32509, uptime 0:00:02
mysqlapi:mysqlapi_85 RUNNING pid 32510, uptime 0:00:02
mysqlapi:mysqlapi_86 RUNNING pid 32507, uptime 0:00:02
mysqlapi:mysqlapi_87 RUNNING pid 32508, uptime 0:00:02
mysqlapi:mysqlapi_88 RUNNING pid 32514, uptime 0:00:02
访问界面:

Más contenido relacionado

Destacado

Line@-keeptocuhme-blake
Line@-keeptocuhme-blakeLine@-keeptocuhme-blake
Line@-keeptocuhme-blakeHuang Blake
 
從 REPL 到 IDE
從 REPL 到 IDE從 REPL 到 IDE
從 REPL 到 IDEJustin Lin
 
用 Python 打造你自己的 summly
用 Python 打造你自己的 summly用 Python 打造你自己的 summly
用 Python 打造你自己的 summlyAndy Dai
 
常用內建模組
常用內建模組常用內建模組
常用內建模組Justin Lin
 
Python簡介和多版本虛擬環境架設
Python簡介和多版本虛擬環境架設Python簡介和多版本虛擬環境架設
Python簡介和多版本虛擬環境架設Tien-Yang (Aiden) Wu
 
除錯、測試與效能
除錯、測試與效能除錯、測試與效能
除錯、測試與效能Justin Lin
 
類別的繼承
類別的繼承類別的繼承
類別的繼承Justin Lin
 
《Python 3.5 技術手冊》第二章草稿
《Python 3.5 技術手冊》第二章草稿《Python 3.5 技術手冊》第二章草稿
《Python 3.5 技術手冊》第二章草稿Justin Lin
 
open() 與 io 模組
open() 與 io 模組open() 與 io 模組
open() 與 io 模組Justin Lin
 
資料永續與交換
資料永續與交換資料永續與交換
資料永續與交換Justin Lin
 
型態與運算子
型態與運算子型態與運算子
型態與運算子Justin Lin
 
從模組到類別
從模組到類別從模組到類別
從模組到類別Justin Lin
 
MicroPython簡介
MicroPython簡介 MicroPython簡介
MicroPython簡介 Max Lai
 
用 Python 玩 LHC 公開數據
用 Python 玩 LHC 公開數據用 Python 玩 LHC 公開數據
用 Python 玩 LHC 公開數據Yuan CHAO
 
流程語法與函式
流程語法與函式流程語法與函式
流程語法與函式Justin Lin
 
以太坊智能合約撰寫簡單教學
以太坊智能合約撰寫簡單教學以太坊智能合約撰寫簡單教學
以太坊智能合約撰寫簡單教學Nicholas Lin
 
第二堂 學習 Java 語法 (1) Java 歷史與程序開發
第二堂 學習 Java 語法 (1) Java 歷史與程序開發第二堂 學習 Java 語法 (1) Java 歷史與程序開發
第二堂 學習 Java 語法 (1) Java 歷史與程序開發力中 柯
 
並行與平行
並行與平行並行與平行
並行與平行Justin Lin
 

Destacado (20)

Line@-keeptocuhme-blake
Line@-keeptocuhme-blakeLine@-keeptocuhme-blake
Line@-keeptocuhme-blake
 
從 REPL 到 IDE
從 REPL 到 IDE從 REPL 到 IDE
從 REPL 到 IDE
 
用 Python 打造你自己的 summly
用 Python 打造你自己的 summly用 Python 打造你自己的 summly
用 Python 打造你自己的 summly
 
常用內建模組
常用內建模組常用內建模組
常用內建模組
 
Python簡介和多版本虛擬環境架設
Python簡介和多版本虛擬環境架設Python簡介和多版本虛擬環境架設
Python簡介和多版本虛擬環境架設
 
資料結構
資料結構資料結構
資料結構
 
除錯、測試與效能
除錯、測試與效能除錯、測試與效能
除錯、測試與效能
 
類別的繼承
類別的繼承類別的繼承
類別的繼承
 
《Python 3.5 技術手冊》第二章草稿
《Python 3.5 技術手冊》第二章草稿《Python 3.5 技術手冊》第二章草稿
《Python 3.5 技術手冊》第二章草稿
 
例外處理
例外處理例外處理
例外處理
 
open() 與 io 模組
open() 與 io 模組open() 與 io 模組
open() 與 io 模組
 
資料永續與交換
資料永續與交換資料永續與交換
資料永續與交換
 
型態與運算子
型態與運算子型態與運算子
型態與運算子
 
從模組到類別
從模組到類別從模組到類別
從模組到類別
 
MicroPython簡介
MicroPython簡介 MicroPython簡介
MicroPython簡介
 
用 Python 玩 LHC 公開數據
用 Python 玩 LHC 公開數據用 Python 玩 LHC 公開數據
用 Python 玩 LHC 公開數據
 
流程語法與函式
流程語法與函式流程語法與函式
流程語法與函式
 
以太坊智能合約撰寫簡單教學
以太坊智能合約撰寫簡單教學以太坊智能合約撰寫簡單教學
以太坊智能合約撰寫簡單教學
 
第二堂 學習 Java 語法 (1) Java 歷史與程序開發
第二堂 學習 Java 語法 (1) Java 歷史與程序開發第二堂 學習 Java 語法 (1) Java 歷史與程序開發
第二堂 學習 Java 語法 (1) Java 歷史與程序開發
 
並行與平行
並行與平行並行與平行
並行與平行
 

Similar a 使用Supervisor守护python进程

Mysql mmm演讲--冯浩
Mysql mmm演讲--冯浩Mysql mmm演讲--冯浩
Mysql mmm演讲--冯浩chinafenghao
 
Mysql mmm演讲-冯浩
Mysql mmm演讲-冯浩Mysql mmm演讲-冯浩
Mysql mmm演讲-冯浩chinafenghao
 
Mysql mmm演讲-冯浩
Mysql mmm演讲-冯浩Mysql mmm演讲-冯浩
Mysql mmm演讲-冯浩chinafenghao
 
如何幫樹莓派安裝常用的Python套件(How to Install Python Package on Raspberry Pi)
如何幫樹莓派安裝常用的Python套件(How to Install Python Package on Raspberry Pi)如何幫樹莓派安裝常用的Python套件(How to Install Python Package on Raspberry Pi)
如何幫樹莓派安裝常用的Python套件(How to Install Python Package on Raspberry Pi)Yanwei Liu
 
Puppet安装总结
Puppet安装总结Puppet安装总结
Puppet安装总结Yiwei Ma
 
Linux network monitoring hands-on pratice
Linux network monitoring hands-on praticeLinux network monitoring hands-on pratice
Linux network monitoring hands-on praticeKenny (netman)
 
快快樂樂學 Scrapy
快快樂樂學 Scrapy快快樂樂學 Scrapy
快快樂樂學 Scrapyrecast203
 
Nagios的安装部署和与cacti的整合(linuxtone)
Nagios的安装部署和与cacti的整合(linuxtone)Nagios的安装部署和与cacti的整合(linuxtone)
Nagios的安装部署和与cacti的整合(linuxtone)Yiwei Ma
 
使用 Load Balancer 與 Redis 部署 LAMP Server 高併發架構 - Global Azure Taiwan 20200425 ...
使用 Load Balancer 與 Redis 部署 LAMP Server 高併發架構 - Global Azure Taiwan 20200425 ...使用 Load Balancer 與 Redis 部署 LAMP Server 高併發架構 - Global Azure Taiwan 20200425 ...
使用 Load Balancer 與 Redis 部署 LAMP Server 高併發架構 - Global Azure Taiwan 20200425 ...Laird Cheng
 
Admin generator
Admin generatorAdmin generator
Admin generatorRicky Su
 
Squid安装配置
Squid安装配置Squid安装配置
Squid安装配置Yiwei Ma
 
Python meetup 1
Python meetup 1Python meetup 1
Python meetup 1Vic Yang
 
Automate with Ansible basic (2/e)
Automate with Ansible basic (2/e)Automate with Ansible basic (2/e)
Automate with Ansible basic (2/e)Chu-Siang Lai
 
Ruby on Rails 開發環境建置 for Ubuntu
Ruby on Rails 開發環境建置 for UbuntuRuby on Rails 開發環境建置 for Ubuntu
Ruby on Rails 開發環境建置 for UbuntuMarsZ Chen
 
現代 IT 人一定要知道的 Ansible 自動化組態技巧 Ⅱ - Roles & Windows
現代 IT 人一定要知道的 Ansible 自動化組態技巧 Ⅱ - Roles & Windows現代 IT 人一定要知道的 Ansible 自動化組態技巧 Ⅱ - Roles & Windows
現代 IT 人一定要知道的 Ansible 自動化組態技巧 Ⅱ - Roles & WindowsChu-Siang Lai
 
Continuous Delivery with Ansible x GitLab CI
Continuous Delivery with Ansible x GitLab CIContinuous Delivery with Ansible x GitLab CI
Continuous Delivery with Ansible x GitLab CIChu-Siang Lai
 
高性能LAMP程序设计
高性能LAMP程序设计高性能LAMP程序设计
高性能LAMP程序设计fuchaoqun
 
使用 Pytest 進行單元測試 (PyCon TW 2021)
使用 Pytest 進行單元測試 (PyCon TW 2021)使用 Pytest 進行單元測試 (PyCon TW 2021)
使用 Pytest 進行單元測試 (PyCon TW 2021)Max Lai
 
Node.js從無到有 基本課程
Node.js從無到有 基本課程Node.js從無到有 基本課程
Node.js從無到有 基本課程Simon Su
 

Similar a 使用Supervisor守护python进程 (20)

Mysql mmm演讲--冯浩
Mysql mmm演讲--冯浩Mysql mmm演讲--冯浩
Mysql mmm演讲--冯浩
 
Mysql mmm演讲-冯浩
Mysql mmm演讲-冯浩Mysql mmm演讲-冯浩
Mysql mmm演讲-冯浩
 
Mysql mmm演讲-冯浩
Mysql mmm演讲-冯浩Mysql mmm演讲-冯浩
Mysql mmm演讲-冯浩
 
如何幫樹莓派安裝常用的Python套件(How to Install Python Package on Raspberry Pi)
如何幫樹莓派安裝常用的Python套件(How to Install Python Package on Raspberry Pi)如何幫樹莓派安裝常用的Python套件(How to Install Python Package on Raspberry Pi)
如何幫樹莓派安裝常用的Python套件(How to Install Python Package on Raspberry Pi)
 
Puppet安装总结
Puppet安装总结Puppet安装总结
Puppet安装总结
 
Linux network monitoring hands-on pratice
Linux network monitoring hands-on praticeLinux network monitoring hands-on pratice
Linux network monitoring hands-on pratice
 
快快樂樂學 Scrapy
快快樂樂學 Scrapy快快樂樂學 Scrapy
快快樂樂學 Scrapy
 
Nagios的安装部署和与cacti的整合(linuxtone)
Nagios的安装部署和与cacti的整合(linuxtone)Nagios的安装部署和与cacti的整合(linuxtone)
Nagios的安装部署和与cacti的整合(linuxtone)
 
使用 Load Balancer 與 Redis 部署 LAMP Server 高併發架構 - Global Azure Taiwan 20200425 ...
使用 Load Balancer 與 Redis 部署 LAMP Server 高併發架構 - Global Azure Taiwan 20200425 ...使用 Load Balancer 與 Redis 部署 LAMP Server 高併發架構 - Global Azure Taiwan 20200425 ...
使用 Load Balancer 與 Redis 部署 LAMP Server 高併發架構 - Global Azure Taiwan 20200425 ...
 
Admin generator
Admin generatorAdmin generator
Admin generator
 
Squid安装配置
Squid安装配置Squid安装配置
Squid安装配置
 
Python meetup 1
Python meetup 1Python meetup 1
Python meetup 1
 
Automate with Ansible basic (2/e)
Automate with Ansible basic (2/e)Automate with Ansible basic (2/e)
Automate with Ansible basic (2/e)
 
Ruby on Rails 開發環境建置 for Ubuntu
Ruby on Rails 開發環境建置 for UbuntuRuby on Rails 開發環境建置 for Ubuntu
Ruby on Rails 開發環境建置 for Ubuntu
 
現代 IT 人一定要知道的 Ansible 自動化組態技巧 Ⅱ - Roles & Windows
現代 IT 人一定要知道的 Ansible 自動化組態技巧 Ⅱ - Roles & Windows現代 IT 人一定要知道的 Ansible 自動化組態技巧 Ⅱ - Roles & Windows
現代 IT 人一定要知道的 Ansible 自動化組態技巧 Ⅱ - Roles & Windows
 
Continuous Delivery with Ansible x GitLab CI
Continuous Delivery with Ansible x GitLab CIContinuous Delivery with Ansible x GitLab CI
Continuous Delivery with Ansible x GitLab CI
 
高性能LAMP程序设计
高性能LAMP程序设计高性能LAMP程序设计
高性能LAMP程序设计
 
使用 Pytest 進行單元測試 (PyCon TW 2021)
使用 Pytest 進行單元測試 (PyCon TW 2021)使用 Pytest 進行單元測試 (PyCon TW 2021)
使用 Pytest 進行單元測試 (PyCon TW 2021)
 
Node.js從無到有 基本課程
Node.js從無到有 基本課程Node.js從無到有 基本課程
Node.js從無到有 基本課程
 
Pipi pi
Pipi piPipi pi
Pipi pi
 

使用Supervisor守护python进程

  • 1. 使用 Supervisor 守护 Python 进程 Author:guosong@staff.sina.com.cn 1、需求 现在有一个进程需要每时每刻不断的跑,但是这个进程又有可能由于各种原因有可能中断。当进 程中断的时候我希望能自动重新启动它,此时,就需要使用到了 Supervisor。Supervisor 起 到守护进程的作用。 2、安装 https://pypi.python.org/pypi/supervisor tar zxvf supervisor-3.0.tar.gz cd supervisor-3.0 python2.7 setup.py build python2.7 setup.py install 需要依赖于 meld3-1.0.0.tar.gz,联网安装,由于所在机器无法上网,故进行手动安装 meld。 参照上面方法再进行安装 meld,安装完成之后再次进行 install 即可。 测试安装是否成功:echo_supervisord_conf 配置文件:echo_supervisord_conf > /etc/supervisord.conf 3、Supervisor 相关 supervisord : supervisor 的服务器端部分,启动 supervisor 就是运行这个命令 supervisorctl:启动 supervisor 的命令行窗口 4、Demo1 测试
  • 2. 需求是对本地的 API 进程进行守护,要求这个服务能在意外停止后自动重启。 API 的执行命令为:python2.6 /data1/guosong/mysqlapi/main/api_main.py --port=8005 修改配置文件: [program:mysqlapi] command = python2.6 /data1/guosong/mysqlapi/main/api_main.py --port=8005 autostart = true autorestart = true startsecs = 3 stdout_logfile = /data1/guosong/mysqlapi/log/mysqlapi_demo1.log 启动 supervisord: [root@typhoeus79 mysqlapi]# ps aux |grep super root 15377 0.0 0.0 61268 788 pts/3 R+ 16:23 0:00 grep super [root@typhoeus79 mysqlapi]# supervisord Unlinking stale socket /var/tmp/supervisor.sock [root@typhoeus79 mysqlapi]# ps aux |grep super root 15458 0.0 0.0 147148 7976 ? Ss 16:23 0:00 /usr/bin/python /usr/bin/supervisord root 15533 0.0 0.0 61268 792 pts/3 S+ 16:23 0:00 grep super 查看进程状态: [root@typhoeus79 mysqlapi]# supervisorctl mysqlapi RUNNING pid 15460, uptime 0:01:19 supervisor> status mysqlapi RUNNING pid 15460, uptime 0:01:21 supervisor> exit [root@typhoeus79 mysqlapi]# ps aux |grep 8005 root 15460 0.2 0.0 208436 15484 ? S 16:23 0:00 python2.6 /data1/guosong/mysqlapi/main/api_main.py --port=8005 root 16314 0.0 0.0 61268 788 pts/3 S+ 16:24 0:00 grep 8005 [root@typhoeus79 mysqlapi]# kill 测试: [root@typhoeus79 mysqlapi]# ps aux |grep 8005 root 15460 0.2 0.0 208436 15484 ? S 16:23 0:00 python2.6 /data1/guosong/mysqlapi/main/api_main.py --port=8005 root 16314 0.0 0.0 61268 788 pts/3 S+ 16:24 0:00 grep 8005
  • 3. [root@typhoeus79 mysqlapi]# [root@typhoeus79 mysqlapi]# kill 15460 [root@typhoeus79 mysqlapi]# ps aux |grep 8005 root 17431 21.0 0.0 208436 15484 ? S 16:25 0:00 python2.6 /data1/guosong/mysqlapi/main/api_main.py --port=8005 root 17437 0.0 0.0 61268 772 pts/3 R+ 16:25 0:00 grep 8005 [root@typhoeus79 mysqlapi]# kill -9 17431 [root@typhoeus79 mysqlapi]# ps aux |grep 8005 |grep -v grep root 17540 7.0 0.0 208440 15488 ? S 16:25 0:00 python2.6 /data1/guosong/mysqlapi/main/api_main.py --port=8005 [root@typhoeus79 mysqlapi]# 使用 kill 以及 kill -9 进程的 id 都发生变化 使用 supervisorctl 进行程序重启: [root@typhoeus79 mysqlapi]# supervisorctl stop all mysqlapi: stopped [root@typhoeus79 mysqlapi]# ps aux |grep 8005 |grep -v grep [root@typhoeus79 mysqlapi]# supervisorctl start all mysqlapi: started [root@typhoeus79 mysqlapi]# ps aux |grep 8005 |grep -v grep root 19649 3.0 0.0 208440 15488 ? S 16:28 0:00 python2.6 /data1/guosong/mysqlapi/main/api_main.py --port=8005 [root@typhoeus79 mysqlapi]# 5、Demo2 测试 守护多个进程,修改/etc/supervisord.conf 配置 [program:mysqlapi] command=python26 /data1/guosong/mysqlapi/main/api_main.py --port=140%(process_num)02d process_name=%(program_name)s_%(process_num)02d ; process_name expr (default %(program_name)s) numprocs=8 numprocs_start=81 startretries=3 stopwaitsecs=10
  • 4. autorstart=true log_stdout=true log_stderr=true logfile=/data1/guosong/mysqlapi/log/mysql_api_demo.log 超过 2 位数如何表示? command=python26 /data1/guosong/mysqlapi/main/api_main.py --port=140%(process_num)02d 结果演示: 6、问题集锦 问题 1-mysqlapi entered FATAL state, too many start retries too quickly: 2014-05-15 17:26:30,898 INFO exited: mysqlapi (exit status 1; not expected) 2014-05-15 17:26:30,899 INFO received SIGCLD indicating a child quit 2014-05-15 17:26:31,901 INFO gave up: mysqlapi entered FATAL state, too many start retries too quickly 原因在于版本导致,api 的脚本版本为 python26,故使用 supervisord 也需要使用 python26 进行安装,查看进程信息如下: root 24058 0.0 0.0 151420 10204 ? Ss 18:28 0:00 /usr/bin/python26 /usr/bin/supervisord -c /etc/supervisord.conf 问题 2- http://127.0.0.1:9001 refused connection: [root@typhoeus79 20140515]# supervisorctl http://10.75.xxx.xxx:9001 refused connection
  • 5. 原因在于没有开启 inet_http_server,配置文件默认使用分号注释每行 将 inet_http_server 前面的分号去除后,重新开启 supervisord [root@typhoeus79 20140515]# /etc/init.d/supervisord stop Stopping supervisord: [ OK ] [root@typhoeus79 20140515]# supervisord -c /etc/supervisord.conf [root@typhoeus79 20140515]# supervisorctl mysqlapi:mysqlapi_81 RUNNING pid 32513, uptime 0:00:02 mysqlapi:mysqlapi_82 RUNNING pid 32511, uptime 0:00:02 mysqlapi:mysqlapi_83 RUNNING pid 32512, uptime 0:00:02 mysqlapi:mysqlapi_84 RUNNING pid 32509, uptime 0:00:02 mysqlapi:mysqlapi_85 RUNNING pid 32510, uptime 0:00:02 mysqlapi:mysqlapi_86 RUNNING pid 32507, uptime 0:00:02 mysqlapi:mysqlapi_87 RUNNING pid 32508, uptime 0:00:02 mysqlapi:mysqlapi_88 RUNNING pid 32514, uptime 0:00:02 访问界面: