我像这样用主管运行docker容器:
Docker文件
CMD ["/run.sh"]
运行
#!/usr/bin/env bash
exec supervisord -n
Supervisor-serf.conf
[group:job]
programs=serf,producer
[program:serf]
command=/start-serf-agent.sh
numprocs=1
autostart=true
autorestart=unexpected
stopasgroup=true
killasgroup=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
start-self-agent.sh
#!/bin/bash
exec serf agent --join=serf:7946 -tag role=producer
主管服务
[program:producer]
command=/start.sh
numprocs=1
stopasgroup=true
killasgroup=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
start.sh
#!/bin/bash
exec /producer --project=${NAME}
生产者停止后,我得到:
producer_1 | 2016/02/29 21:59:50 [INFO] serf: EventMemberLeave: 7c4fbc80af97 172.19.0.2
producer_1 | 2016/02/29 21:59:51 INF 1 stopping
producer_1 | 2016/02/29 21:59:51 INF 1 exiting router
producer_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
但是农奴代理会保持容器处于运行状态。当生产者以状态0正确完成工作时,我想停止Docker容器。我尝试将进程加入一个组,但似乎不起作用。伙计们,我跳过了什么?请帮帮我!
可能是serverfault.com/questions/735328/…的
—
ibotty