如何在Supervisord中设置一个进程组?

32

我正在设置 supervisord 并尝试控制多个进程,这部分工作很好,现在我想设置一个组,以便可以启动/停止不同的进程集而不是全部启动或停止。这是我的配置文件的一部分:

[group:tapjoy]
programs=tapjoy-game1,tapjoy-game2

[program:tapjoy-game1]
command=python tapjoy_pinger.py -g game1
directory=/go/here/first
redirect_stderr=true
autostart=true
autorestart=true
stopasgroup=true
killasgroup=true

[program:tapjoy-game2]
command=python tapjoy_pinger.py -g game2
directory=/go/here/first
redirect_stderr=true
autostart=true
autorestart=true
stopasgroup=true
killasgroup=true

从文档上看,这个命令应该可以工作,但是运行 supervisorctl restart tapjoy: 并没有产生任何效果。

我有什么遗漏的吗?

在命令后加上星号不会报错,但也没有任何作用。

supervisorctl restart tapjoy:*
supervisorctl status
tapjoy_game1                     RUNNING    pid 4697, uptime 1 day, 21:56:23
tapjoy_game2                     RUNNING    pid 4698, uptime 1 day, 21:56:23
tapjoy_game3                     RUNNING    pid 4699, uptime 1 day, 21:56:23
tapjoy_game4                     RUNNING    pid 4700, uptime 1 day, 21:56:23
tapjoy_game5                     RUNNING    pid 4701, uptime 1 day, 21:56:23
2个回答

43

您需要使用通配符 * 来选择一组中的所有程序:

supervisorctl restart tapjoy:*

注意:你的shell可能需要你转义*,通常使用\*进行转义。


@EoghanM:输入 supervisorctl help restart,文档里有详细说明。 - Martijn Pieters
啊,我没意识到在 supervisorctl help 之后还有更多的文档。在线文档中也没有相关内容。 - EoghanM
@EoghanM:该项目存在一个未解决的问题,需要更好地记录这个工具。 - Martijn Pieters
现在您可以使用命令行而不需要 *,例如 supervisorctl restart tapjoy: - wyx

3

我知道这是一个旧的帖子,但是我也遇到了同样的问题,如果能在这里找到答案就太好了。因此,供以后参考,不要使用以下方法:

program=tapjoy-game1,tapjoy-game2

你需要:

programs=tapjoy-game1,tapjoy-game2

文档:http://supervisord.org/configuration.html#group-x-section-values

该文档提供了Supervisor配置文件中的group:x节的所有可能值。这包括进程组的名称,所需的命令,工作目录,环境变量和启动时要使用的用户等信息。


1
那只是一个笔误。我已经纠正了它。问题实际上是需要使用 \* 而不是 *。 - Joshua Olson

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接