how to restart only certain processes using supervisorctl?

I'm running a few processes using supervisord, named process1, process2, ..., process8. If I want to restart process{1-4}, how can I do that with supervisorctl?

150032 次浏览

supervisord supports 程序小组. You can group processes into named groups and manage them collectively.

[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

命令可以用组名称调用:

supervisorctl restart foo:

以及多个进程名称:

supervisorctl restart foo:cat1 cat2

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

supervisorctl restart process{1..4}

在贝壳旁边扩展为

supervisorctl restart process1 process2 process3 process4

就好像你已经明确地打出来了。