主管停止子进程 [英] supervisord stopping child processes

查看:38
本文介绍了主管停止子进程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用 supervisord 时面临的一个问题是,当我有一个命令反过来产生另一个进程时,supervisord 无法杀死它.

One of the problems, I face with supervisord is that when I have a command which in turn spawns another process, supervisord is not able to kill it.

例如我有一个java进程,它在正常运行时就像

For example I have a java process which when runs normally is like

 $ zkServer.sh start-foreground
 $ ps -eaf | grep zk
 user 30404 28280  0 09:21 pts/2    00:00:00 bash zkServer.sh start-foreground
 user 30413 30404 76 09:21 pts/2    00:00:10 java -Dzookeeper.something..something

supervisord 配置文件如下所示:

The supervisord config file looks like:

[program:zookeeper]
command=zkServer.sh start-foreground
autorestart=true
stopsignal=KILL

当涉及到从 supervisorctl 阻止它们时,supervisord 不能很好地处理这些具有多个子进程的进程.因此,当我从 supervisord 运行它并尝试从 supervisorctl 停止它时,只有顶级进程被杀死,而不是实际的 java 进程.

These kind of processes which have multiple childs are not well handled by supervisord when it comes to stopping them from supervisorctl. So when I run this from the supervisord and try to stop it from supervisorctl, only the top level process gets killed but not the actual java process.

推荐答案

Rick Hanlon II 在这里遇到了同样的问题:https://coderwall.com/p/4tcw7w

The same problem was encountered by Rick Hanlon II here: https://coderwall.com/p/4tcw7w

应在程序部分设置选项 stopasgroup=true,以便 supervisord 不仅停止父进程,还停止子进程.

Option stopasgroup=true should be set in the program section for supervisord to stop not only the parent process but also the child processes.

示例如下:

[program:some_django]
 command=python manage.py runserver
 directory=/dir/to/app
 stopasgroup=true

另外,请记住,您可能有一个没有stopasgroup"功能的更旧的 supervisord 包.我在 Raspberry Pi 上尝试了这些 Debian 软件包:

Also, have in mind that you may have an older package of supervisord that does not have "stopasgroup" functionality. I tried these Debian packages on Raspberry Pi:

  • supervisor_3.0a8 不起作用.
  • supervisor_3.0b2-1 按预期工作.

这篇关于主管停止子进程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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