我正在使用Supervisor 的事件框架来订阅由 Supervisor 管理的进程的事件。
我的事件监听器,processlistener.py
看起来像这样:
import sys
from supervisor.childutils import listener
def write_stdout(s):
sys.stdout.write(s)
sys.stdout.flush()
def write_stderr(s):
sys.stderr.write(s)
sys.stderr.flush()
def main():
while True:
headers, body = listener.wait(sys.stdin, sys.stdout)
body = dict([pair.split(":") for pair in body.split(" ")])
write_stderr("Headers: %r\n" % repr(headers))
write_stderr("Body: %r\n" % repr(body))
if headers["eventname"] == "PROCESS_STATE_RUNNING":
write_stderr("Process state running...\n")
if __name__ == '__main__':
main()
在我的supervisord.conf
,我有:
[program:theprogramname]
command=/bin/cat ; the program (relative uses PATH, can take args)
process_name=%(program_name)s_%(process_num)s ; process_name expr (default %(program_name)s)
numprocs=1 ; number of processes copies to start (def 1)
[eventlistener:theeventlistenername]
command=python processlistener.py ; the program (relative uses PATH, can take args)
process_name=%(program_name)s_%(process_num)s ; process_name expr (default %(program_name)s)
numprocs=1 ; number of processes copies to start (def 1)
events=PROCESS_STATE_RUNNING ; event notif. types to subscribe to (req'd)
使用此配置,我希望只要由 Supervisor 管理的进程进入RUNNING
状态,我的事件侦听器就会收到通知。然而,这种情况并非如此。theprogramname
当我用信号杀死时SIGINT
,主管重新启动了该过程,但我的侦听器没有收到此通知。
为了实现我想要的,我是否缺少额外的配置?