2011-10-26 64 views
6

我在我的Ubuntu 10.04上安裝了supervisord,並且它不斷運行Java進程,並且在它以某種方式死亡或崩潰時應該恢復(重新加載)進程。Supervisord不會啓動死亡進程

在我htop我送SIGKILL,SIGTERM,SIGHUP,SIGSEGV信號到Java進程,看/etc/logs/supervisord.log文件,它說。

08:09:46,182 INFO success: myprogram entered RUNNING state,[...] 
08:38:10,043 INFO exited: myprogram (exit status 0; expected) 

08:38我用SIGSEGV殺死進程。爲什麼代碼0退出,爲什麼supervisord根本沒有重啓?

我所有的supervisord.conf關於這個具體方案如下:當我啓動supervisord

[program:play-9000] 
command=play run /var/www/myprogram/ --%%prod 
stderr_logfile = /var/log/supervisord/myprogram-stderr.log 
stdout_logfile = /var/log/supervisord/myprogram-stdout.log 

工藝作品真的很好,但是沒有得到痊癒。

順便說一句,如何啓動supervisord作爲服務,以便它在整個系統重新啓動時自動啓動的任何想法?

回答

11

嘗試設置autorestart=true。默認情況下,autorestart設置爲「意外」,這意味着如果存在意外的退出代碼,它將僅重新啓動一個進程。默認情況下,預計退出代碼爲0。

http://supervisord.org/configuration.html#program-x-section-settings

您可以使用chkconfig程序,以確保主管在重新啓動時啓動。

$ sudo apt-get install chkconfig 
$ chkconfig -l supervisor 
supervisor    0:off 1:off 2:on 3:on 4:on 5:on 6:off 

當我安裝它時,可以看到默認啓用運行級別2-5。

$ man 7 runlevel 

有關運行級別的更多信息。

+0

非常棒!我正在尋找這個'autorestart'設置。我期待它默認爲'true',然後我迷失在文檔中。順便說一句,我認爲'chkconfig'需要一個進程是一個服務,然而'supervisord'不是一個服務,因此'chkconfig -l'命令不適用於我,並且說'supervisor:無法識別的服務'。你對此有什麼看法? –

+1

你是如何安裝主管的?如果您使用apt-get,那麼它將作爲服務安裝,至少對於Ubuntu 10.04來說。 –

+0

它在10.04上,我想我使用'easy_install'安裝了它。感謝您注意到這一點。 –