问题
I am using supervisord inside docker to run two processes:
- the main process and
- an ssh tunnel needed by the main process
When the main process stops normally, the ssh tunnel process stays alive forever, preventing the docker from stopping. This is problematic as the container runs as a Kubernetes job, that needs to terminate when the main process finished.
The question is, is it possible to kill the ssh tunnel when the main process stops or even better: stopping supervisord when the main process stopped?
回答1:
use event listner
:
[eventlistener:MyMainProcessName]
command=kill -3 $(cat "/var/run/supervisord.pid")
process_name=MyMainProcessName
events=PROCESS_STATE_STOPPED, PROCESS_STATE_EXITED, PROCESS_STATE_FATAL
that will send SIGQUIT
to Supervisor if that process stopped
来源:https://stackoverflow.com/questions/58131968/how-to-stop-supervisord-when-a-specific-program-stopped-normally