歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> Supervisor管理hhvm進程

Supervisor管理hhvm進程

日期:2017/2/27 15:56:40   编辑:Linux教程
hhvm速度很快,但由於與網站程序兼容性或hhvm本身不成熟,跑一段時間後會出現hhvm宕掉,使前台頁面出現502 bad gateway。為了防止hhvm進程自動宕掉,我們可以用Supervisor來管理hhvm進程,它會在hhvm宕掉後自動啟動hhvm進程。
Supervisor已經加到《lnmp一鍵安裝包》,歡迎測試。

HHVM相關教程請參考如下:
CentOS 7下hhvm Nginx環境搭建:http://blog.linuxeye.com/402.html
CentOS 6下hhvm Nginx環境搭建:http://blog.linuxeye.com/396.html

Supervisor簡介
Supervisor是一個Python開發的client/server系統,可以管理和監控*nix上面的進程。

部件
Supervisor有不同的部件組成,部件分別負責不同的功能,對進程進行監控和管理。

supervisord
Supervisor的server部分稱為supervisord。主要負責管理子進程,響應客戶端的命令,log子進程的輸出,創建和處理不同的事件

supervisorctl
Supervisor的命令行客戶端。它可以與不同的supervisord進程進行通信,獲取子進程信息,管理子進程

Web Server
Supervisor的web server,用戶可以通過web對子進程進行監控,管理等等,作用與supervisorctl一致。

XML-RPC interface
XML-RPC接口,提供XML-RPC服務來對子進程進行管理,監控

安裝Supervisor
安裝supervisor很簡單,通過easy_install就可以安裝
yum -y install python-setuptools

easy_install supervisor

安裝完成之後,就可以用echo_supervisord_conf命令來生成配置文件
echo_supervisord_conf > /etc/supervisord.conf
配置supervisor管理hhvm進程
vi /etc/supervisord.conf pidfile=/tmp/supervisord.pid 改成 pidfile=/var/run/supervisord.pid
#並在/etc/supervisord.conf後面追加如下內容:
[program:hhvm]
command=/usr/bin/hhvm --mode server --user www --config /etc/hhvm/server.ini --config /etc/hhvm/php.ini --config /etc/hhvm/config.hdf
numprocs=1 ; number of processes copies to start (def 1)
directory=/tmp ; directory to cwd to before exec (def no cwd)
autostart=true ; start at supervisord start (default: true)
autorestart=unexpected ; whether/when to restart (default: unexpected)
stopwaitsecs=10 ; max num secs to wait b4 SIGKILL (default 10)

supervisor開機腳本
wget https://github.com/Supervisor/initscripts/raw/master/redhat-init-mingalevme
/bin/mv redhat-init-mingalevme /etc/init.d/supervisord
chmod +x /etc/init.d/supervisord
chkconfig supervisord on

service supervisord restart

測試Supervistor
原文:http://blog.linuxeye.com/408.html
Copyright © Linux教程網 All Rights Reserved