2016-07-27 6 views
0

나는 이전 응답을 보았지만 응답은 없었습니다. 솔루션을 아는 사람이 도움이되기를 바랍니다.하나의 프로세스가 충돌하거나 사망 할 때 Supervisord restart 그룹

감독자 프로세스 그룹에 한 명의 회원이있는 경우 해당 그룹의 모든 회원을 다시 시작할 수 있습니까?

또는 그룹을 다시 시작하기 위해 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() 

,하지만 일을하는 가장 좋은 방법은 아닙니다.