Ubuntu 如何停止暴发户作业的所有实例
我有以下upstart作业,它使用参数运行同一作业的多个实例:Ubuntu 如何停止暴发户作业的所有实例,ubuntu,upstart,Ubuntu,Upstart,我有以下upstart作业,它使用参数运行同一作业的多个实例: instance $ARG1,$ARG2 script exec /path/to/executable "$ARG1" "ARG2" end script 现在,如果我像这样开始两个工作实例: $ start my-job ARG1=ABCD ARG2=1 my-job (ABCD,1) start/running, process 6242 $ start my-job ARG1=EFGH ARG2=2 my-jo
instance $ARG1,$ARG2
script
exec /path/to/executable "$ARG1" "ARG2"
end script
现在,如果我像这样开始两个工作实例:
$ start my-job ARG1=ABCD ARG2=1
my-job (ABCD,1) start/running, process 6242
$ start my-job ARG1=EFGH ARG2=2
my-job (EFGH,2) start/running, process 6254
如何在一个命令中停止my job
的所有实例,除了在initctl list
上执行grep、提取运行my job
实例的参数以及对每个实例执行stop
我已尝试
停止我的作业
和停止我的作业ARG1=\*ARG2=\*
。两者都不起作用。我最后做了以下工作,它与[start | stop | restart]svc一起工作
scv.conf:
svc instance.conf:
启动svc任务。conf:
停止我的作业任务。conf:
亲自查看您的案例是否需要status | | start
和status&&stop | | continue
逻辑。我应该注意到,我最初的用例只需要一个实例变量,我没有用两个这样的变量来测试它。使用信号。通过执行initctl emit scv stop
scv.conf:
description "An Example Service Starter"
start on networking
stop on runlevel[06]
for addr in 10.10.10.1 10.10.10.2 10.10.10.3 10.10.10.4;
{
for port in 4001 4002 4003 4004;
{
status svc-n $addr:$port || start svc-n ADDR=$addr PORT=$port
}
}
script
scv-n.conf
description "An Example Service Instance"
instance $ADDR:$PORT
stop on runlevel[06] or scv-stop
script
exec /opt/svc/bin/svc -a $ADDR -p $PORT
end script
我想停止我的工作ARG1=EFGH ARG2=2
行得通吧?我可能不支持windcards。@errordeveloper是的,这很有效。但我希望能够一次完成我所有的工作。
start on starting svc
task
script
for a in 10.10.10.1 10.10.10.2 10.10.10.3 10.10.10.4
do
for p in 4001 4002 4003 4004
do status svc-instance ADDR=$a PORT=$p \
|| start svc-instance ADDR=$a PORT=$p \
done
done
end script
start on stopping svc
task
script
for a in 10.10.10.1 10.10.10.2 10.10.10.3 10.10.10.4
do
for p in 2001 2002 2003 2004
do status svc-instance ADDR=$a PORT=$p \
&& stop svc-instance ADDR=$a PORT=$p \
|| continue
done
done
end script
description "An Example Service Starter"
start on networking
stop on runlevel[06]
for addr in 10.10.10.1 10.10.10.2 10.10.10.3 10.10.10.4;
{
for port in 4001 4002 4003 4004;
{
status svc-n $addr:$port || start svc-n ADDR=$addr PORT=$port
}
}
script
description "An Example Service Instance"
instance $ADDR:$PORT
stop on runlevel[06] or scv-stop
script
exec /opt/svc/bin/svc -a $ADDR -p $PORT
end script