0
我見過一些較舊的帖子詢問這個,但沒有迴應。希望知道解決方案的人可以幫助Supervisord重啓組,當一個進程崩潰/被殺死
如果supervisord進程組有一個成員關閉,是否可以重新啓動該組中的所有成員?
或者我可以讓一個EventListener重新啓動組,但我希望從supervisord獲得更優雅的解決方案。
謝謝!
我見過一些較舊的帖子詢問這個,但沒有迴應。希望知道解決方案的人可以幫助Supervisord重啓組,當一個進程崩潰/被殺死
如果supervisord進程組有一個成員關閉,是否可以重新啓動該組中的所有成員?
或者我可以讓一個EventListener重新啓動組,但我希望從supervisord獲得更優雅的解決方案。
謝謝!
作爲一個臨時解決方案,一個可以做以下
以下內容添加到您的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()
這將做你想做的,但這不是做事情的最好方式(imo)。