/
githubmirror
/
commcare-hq
Обзор
Документация
Войти
/
githubmirror
/
commcare-hq
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
scripts/supervisor-group-ctl
45 строк
895 B
Simon Kelly
protect against empty process list
18 дек 2019, 17:57
18 дек 2019, 17:57
1666b2a
Код
Авторство
О чём код?
#!/bin/bash command=$1 group=$2 function print_usage() { # This is bash's way of printing a multiline string cat << EOF usage: $0 [stop|start|restart] [celery|pillowtop] This script stops, starts, or restarts all pillowtop processes using supervisorctl EOF } # verify command is valid and print usage otherwise case $command in stop|start|restart) ;; *) print_usage exit 1 ;; esac case $group in celery) pattern='\-celery' ;; pillowtop) pattern='\-pillowtop-' ;; *) print_usage exit 1 ;; esac # grep supervisor status for all processes containing the pattern # strip away everything except just the process name # and pass that to supervisorctl as args processes=$(sudo supervisorctl status | grep "$pattern" | cut -d' ' -f1) if [ -n "$processes" ]; then echo "$processes" | xargs -n 1 -P 10 sudo supervisorctl $command fi