当特定程序正常停止时如何停止监督 [英] How to stop supervisord when a specific program stopped normally

查看:79
本文介绍了当特定程序正常停止时如何停止监督的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在docker内部使用 supervisord 来运行两个进程:

I am using supervisord inside docker to run two processes:

  1. 主要过程和
  2. 主要流程所需的ssh隧道

当主进程正常停止时,ssh隧道进程将永远保持活动状态,从而防止docker停止.这是有问题的,因为容器是作为Kubernetes作业运行的,需要在主进程完成时终止.

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.

问题是,是否可以在主进程停止时杀死ssh隧道,甚至更好:在主进程停止时停止受监管的ssh隧道?

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?

推荐答案

使用事件列表器:

[eventlistener:MyMainProcessName]
command=kill -3 $(cat "/var/run/supervisord.pid")
process_name=MyMainProcessName
events=PROCESS_STATE_STOPPED, PROCESS_STATE_EXITED, PROCESS_STATE_FATAL

如果该进程停止,它将向管理员发送 SIGQUIT

that will send SIGQUIT to Supervisor if that process stopped

这篇关于当特定程序正常停止时如何停止监督的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆