diff options
author | Christian Pointner <equinox@spreadspace.org> | 2014-10-08 18:43:02 +0200 |
---|---|---|
committer | Christian Pointner <equinox@spreadspace.org> | 2014-10-08 18:43:02 +0200 |
commit | 0bf931cf12c66abfd58e70dd1cf3659e828a8725 (patch) | |
tree | 4d2c63bb07f05825599bf25413b66e7275d5c5c0 /scripts/sydra-manager.sh | |
parent | fixed locale issue at command line parser (diff) |
added scripts and configs for supervisord
Diffstat (limited to 'scripts/sydra-manager.sh')
-rwxr-xr-x | scripts/sydra-manager.sh | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/scripts/sydra-manager.sh b/scripts/sydra-manager.sh new file mode 100755 index 0000000..093d557 --- /dev/null +++ b/scripts/sydra-manager.sh @@ -0,0 +1,60 @@ +#!/bin/bash + +############################ + +ROOT_D="$1" +GROUP_NAME="$2" + +############################ + +printUsage() { + echo "Usage: $0 <basedir> <groupname>" +} + +if [ -z "$ROOT_D" ] || [ -z "$GROUP_NAME" ]; then + printUsage + exit 1 +fi +if [ ! -d "$ROOT_D" ]; then + echo "ERROR: can't change to non-existent directory: $ROOT_D" + exit 2 +fi + +. ./include.sh + +PIPE="$ROOT_D/sydra-manager.sock" +trap "rm -f $PIPE" EXIT +if [[ ! -p $PIPE ]]; then + mkfifo $PIPE +fi + +cd "$ROOT_D" +echo "00" > show-stream.current + +while true +do + if read line <$PIPE; then + cmd=${line%% *} + arg=${line##* } + case $cmd in + restart) + get_num $arg + if [ -z "$NUM" ]; then NUM=$arg; fi + supervisorctl restart "$GROUP_NAME:$NUM" + NUM='' + ;; + select) + get_num $arg + if [ -n "$NUM" ]; then + echo "$NUM" > show-stream.current + supervisorctl restart "$GROUP_NAME:main" + fi + NUM='' + ;; + *) + ;; + esac + fi +done + +exit 0 |