我最近使用PHP5-FPM,Gearman和Supervisor設置了Ubuntu Natty。我編輯了我的Supervisord配置文件來運行Gearman worker。Supervisord爲PHP和Gearman添加多個進程
[program:gearman]
command=/usr/bin/php php_gearman_worker.php
numprocs=1
directory=/root/sandbox
stdout_logfile=/root/sandbox/supervisord.log
environment=GEARMAN_USER=gearman
autostart=true
autorestart=true
user=gearman
這裏的相關信息(只顯示gearmand和PHP程序),當我lsof -i -P
之前,我跑supervisord:
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
gearmand 29314 gearman 6u IPv4 328139 0t0 TCP localhost:4730 (LISTEN)
這裏就是我得到的,當我lsof -i -P
後,我/etc/init.d/supervisor stop && /etc/init.d/supervisor start
。
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
gearmand 29314 gearman 6u IPv4 328139 0t0 TCP localhost:4730 (LISTEN)
gearmand 29314 gearman 11u IPv4 328206 0t0 TCP localhost:4730->localhost:39072 (ESTABLISHED)
php 29571 gearman 4u IPv4 329744 0t0 TCP localhost:39072->localhost:4730 (ESTABLISHED)
我沒有看到supervisord本身的任何列表,我應該看到supervisord作爲一個命令?!
無論如何,當我停止和啓動(或重啓)supervisord再次:
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
gearmand 29314 gearman 6u IPv4 328139 0t0 TCP localhost:4730 (LISTEN)
gearmand 29314 gearman 11u IPv4 328206 0t0 TCP localhost:4730->localhost:39072 (ESTABLISHED)
gearmand 29314 gearman 12u IPv4 329754 0t0 TCP localhost:4730->localhost:51570 (ESTABLISHED)
php 29571 gearman 4u IPv4 329744 0t0 TCP localhost:39072->localhost:4730 (ESTABLISHED)
php 29619 gearman 4u IPv4 327233 0t0 TCP localhost:51570->localhost:4730 (ESTABLISHED)
它看起來像每次我停止和啓動supervisord用,它創建另一個PHP過程,然後另一個。只有當我重新啓動gearmand時,它纔會恢復正常,即/etc/init.d/gearman-job-server stop && /etc/init.d/gearman-job-server start
。
這似乎異常對我噓寒問暖,當我停止supervisord,它應該停止
這是supervisord的工作方式?有沒有辦法阻止這種情況的發生?
在此先感謝。
編輯
我發現了什麼是造成問題。這與supervisord.conf和我的init腳本有一點衝突。
我supervisord.conf文件有以下設置:
pidfile=/tmp/supervisord.pid
但在/etc/init.d/supervisord
我的初始化腳本有以下設置:
NAME=supervisord
PIDFILE=/var/run/$NAME.pid
所以我只是改變了設置在supervisord.conf到匹配我的init腳本中的內容。
此外,我添加stopsignal=KILL
到我的supervisord配置文件(supervisord.conf)中的程序配置。
感謝米納斯的方向。
我更新了supervisord.conf文件,並添加了'stopsignal = KILL'但是當我停止supervisord,不知道爲什麼 –
只是好奇,你需要重新啓動supervisord它不會殺死進程經常? – minaz
不,我只是測試系統,以確保一切正常,因爲它應該。它在停止和啓動時執行相同的操作,而不僅僅是重新啓動。我已經找到了問題所在,但是我在問題的編輯中發佈了信息。 –