Dockerfile
CMD ["/run.sh"]
run.sh
#!/usr/bin/env bashexec supervisord -n
主管-serf.conf
[group:job]programs=serf,producer[program:serf]command=/start-serf-agent.shnumprocs=1autostart=trueautorestart=unexpectedstopasgroup=truekillasgroup=truestdout_logfile=/dev/stdoutstdout_logfile_maxbytes=0stderr_logfile=/dev/stderrstderr_logfile_maxbytes=0
start-serf-agent.sh
#!/bin/bashexec serf agent --join=serf:7946 -tag role=producer
主管-servce.conf
[program:producer]command=/start.shnumprocs=1stopasgroup=truekillasgroup=truestdout_logfile=/dev/stdoutstdout_logfile_maxbytes=0stderr_logfile=/dev/stderrstderr_logfile_maxbytes=0
start.sh
#!/bin/bashexec /producer --project=${name}
生产者停止后,我得到了:
producer_1 | 2016/02/29 21:59:50 [INFO] serf: EventMemberLeave: 7c4fbc80af97 172.19.0.2producer_1 | 2016/02/29 21:59:51 INF 1 stopPingproducer_1 | 2016/02/29 21:59:51 INF 1 exiting routerproducer_1 | 2016-02-29 21:59:51,281 INFO exited: producer (exit status 0; expected)producer_1 | 2016/02/29 21:59:51 [INFO] agent: Received event: member-leave
但是serf-agent使容器保持运行状态.当生产者正确地完成他的工作状态0时,我想停止Docker容器.我试图将进程加入到一个组但似乎不起作用.伙计们,我跳过了什么?请帮帮我!
解决方法 我解决了supervisor eventListener的问题:[program:worker]command=/start.shpriority=2process_name=workernumprocs=1stopasgroup=truekillasgroup=truestdout_logfile=/dev/stdoutstdout_logfile_maxbytes=0stderr_logfile=/dev/stderrstderr_logfile_maxbytes=0[eventListener:worker_exit]command=/kill.pyprocess_name=workerevents=PROCESS_STATE_EXITED
kill.py
#!/usr/bin/env pythonimport sysimport osimport signaldef write_stdout(s): sys.stdout.write(s) sys.stdout.flush()def write_stderr(s): sys.stderr.write(s) sys.stderr.flush()def main(): while 1: write_stdout('READY\n') line = sys.stdin.readline() write_stdout('This line kills supervisor: ' + line); try: pIDfile = open('/var/run/supervisord.pID','r') pID = int(pIDfile.readline()); os.kill(pID,signal.SIGQUIT) except Exception as e: write_stdout('Could not kill supervisor: ' + e.strerror + '\n') write_stdout('RESulT 2\nOK')if __name__ == '__main__': main() import sysmain issue I forgot to point to **process_name**
也好文章process management in docker containers
总结以上是内存溢出为你收集整理的linux – 如果退出0结果,如何退出所有管理程序进程全部内容,希望文章能够帮你解决linux – 如果退出0结果,如何退出所有管理程序进程所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)