2016-07-27 6 views
0

私は、ソリューションを知っている誰かが助けてくれることを願っています。1つのプロセスがクラッシュしたり、強制終了された場合のスーパーバイザ再起動グループ

スーパーバイザプロセスグループに1人のメンバーがいる場合、そのグループ内のすべてのメンバーを再起動できますか?

代わりに、私はおそらくグループを再起動するためにEventListenerを作ることができましたが、私はsupervisordからより洗練されたソリューションを望んでいました。

ありがとうございます!

答えて

1

一時的な解決策として、一つは以下の

があなたのconfファイルに以下を追加行うことができます。

; the below section must remain in the config file for RPC 
; (supervisorctl/web interface) to work, additional interfaces may be 
; added by defining them in separate rpcinterface: sections 
[rpcinterface:supervisor] 
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface 

; Event listener, on any kid going down, restart all the children 
[eventlistener:good_listener] 
command=python /path/to/python_script.py 
events=PROCESS_STATE 

、スクリプト:これは、あなたがやりたいだろう

#!/usr/bin/python 
import sys 
from supervisor.childutils import listener 
from subprocess import call 

def write_stderr(s): 
    sys.stderr.write(s) 
    sys.stderr.flush() 

def main(): 
    while 1: 
     cmd_msg, cmd_body = listener.wait(sys.stdin, sys. 

     if 'eventname' in cmd_msg: 
     if cmd_msg['eventname'] == 'PROCESS_STATE_EXITED': 
      write_stderr('Process has quit\n') 
      call(["supervisorctl", "restart", "all"]) 

     listener.ok(sys.stdout) 

if __name__ == '__main__': 
    main() 

しかし、それは物事を行う最善の方法ではありません。

関連する問題