Slide 15
Slide 15 text
#!/bin/bash
declare -A SERVICES
SERVICES=(
['a-service']='8080'
['b-service']='8081'
['c-service']='8082'
)
# kill child processes
trap "pkill -P $$" EXIT
# exclude specific service
if [ $# = 1 ]; then
unset -v SERVICES[$1]
Fi
for service in ${!SERVICES[@]}; do
# retry
(until ./mockingjay-server -config=../${service}.yml -port=${SERVICES[$service]}; do sleep 2; done) &
Done
Sleep 8h 15
サンプル
(bash)
配列作って
引数のもの
を unset
コケた時は until で 2 秒後にリトライ
trap で親プロセスを落とした時に子プロセスも全部落とす