如何使用supervisorctl仅重启某些进程?

Thi*_*yen 98 supervisord

我正在使用supervisord运行一些进程,名为process1,process2,...,process8.如果我想重启进程{1-4},我怎么能用supervisorctl做到这一点?

mhe*_*her 161

supervisord支持进程组.您可以将进程分组到命名组中并集中管理它们.

[unix_http_server]
file=%(here)s/supervisor.sock

[supervisord]
logfile=supervisord.log
pidfile=supervisord.pid

[program:cat1]
command=cat

[program:cat2]
command=cat

[program:cat3]
command=cat

[group:foo]
programs=cat1,cat3

[supervisorctl]
serverurl=unix://%(here)s/supervisor.sock

[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
Run Code Online (Sandbox Code Playgroud)

可以使用组名称调用supervisorctl命令:

supervisorctl restart foo:
Run Code Online (Sandbox Code Playgroud)

以及多个进程名称:

supervisorctl restart foo:cat1 cat2
Run Code Online (Sandbox Code Playgroud)

  • 令人惊讶的是,在向进程组发出命令时需要附加冒号才是非常重要的.谢谢. (43认同)
  • 同意.我认为`supervisorctl restart foo:*`让事情更加清晰. (4认同)

Pau*_*ce. 6

由于supervisorctl在命令行上接受多个进程,您可以利用 shell 括号扩展(例如在 Bash 中)来控制多个进程:

supervisorctl restart process{1..4}
Run Code Online (Sandbox Code Playgroud)

展开成

supervisorctl restart process1 process2 process3 process4
Run Code Online (Sandbox Code Playgroud)

就好像你已经明确地输入了一样。