實作程序服務管理,supervisort監聽到程序死後,會自動将它重新拉起,很友善的做到程序自動恢複的功能,不再需要自己寫shell腳本來控制安裝過程1、到官網下載下傳最新版本,解壓編譯,tar -zxvf supervisor-3.3.4.tar.gzcd supervisor-3.3.4python setup.py install可能會遇到如下錯誤:Installed /usr/lib/python2.7/site-packages/supervisor-3.3.4-py2.7.eggProcessing dependencies for supervisor==3.3.4Searching for meld3>=0.6.5Reading https://pypi.python.org/simple/meld3/Download error on https://pypi.python.org/simple/meld3/: [Errno 1] _ssl.c:504: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed -- Some packages may not be found!Couldn't find index page for 'meld3' (maybe misspelled?)Scanning index of all packages (this may take a while)Reading https://pypi.python.org/simple/Download error on https://pypi.python.org/simple/: [Errno 1] _ssl.c:504: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed -- Some packages may not be found!No local packages or download links found for meld3>=0.6.5error: Could not find suitable distribution for Requirement.parse('meld3>=0.6.5')解決辦法:tar -xf meld3-1.0.1.tar.gzcd meld3-1.0.1python setup.py install重新執行安裝supervisor包生成配置檔案echo_supervisord_conf > /etc/supervisord.conf檢視配置檔案cat /etc/supervisord.conf |grep -v ";"|grep -v "^$"[[email protected] ~]# cat /etc/supervisord.conf |grep -v ";"|grep -v "^$"[unix_http_server][supervisord][rpcinterface:supervisor]supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface[supervisorctl]配置WEB管理程序[inet_http_server]port=127.0.0.1:9001 ; 伺服器ipusername=xxx ;自定義password=xxx ;自定義建立管理配置檔案目錄mkdir /etc/supervisord編輯配置檔案,在配置檔案底部,配置include[include]files=/etc/supervisord/*.conf啟動supervisord -c /etc/supervisord.conf
#在
/etc/supervisord目錄下添加mysql一個執行個體的配置檔案,如下:
[[email protected] supervisord]# cat mysql_3306.conf
[program:mysql_3306]
#command=/etc/init.d/mysql start --port=3306 --sleep=3 --tryies=3 --daemon
command=/usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf --datadir=/var/lib/mysql/ --pid-file=/var/lib/mysql/host-172-16-32-152.pid --basedir=/usr/local/mysql --log-error=/var/lib/mysql/mariadb.log --user=mysql
autostart=true
user=mysql
autorestart=unexpected
numprocs=1
redirect_stderr=true
startsecs=10
stdout_logfile=/var/log/block_push.log
stdout_logfile_maxbytes=1MB
stdout_logfile_backups=10
stdout_capture_maxbytes=1MB
stderr_logfile=/var/log/block_push.log
stderr_logfile_maxbytes=1MB
stderr_logfile_backups=10
stderr_capture_maxbytes=1MB
最後執行:
supervisorctl reload
原文:http://blog.51cto.com/sf1314/2131632