summaryrefslogtreecommitdiff
path: root/scripts/ctrlroom/sydra-manager.sh
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/ctrlroom/sydra-manager.sh')
-rwxr-xr-xscripts/ctrlroom/sydra-manager.sh70
1 files changed, 70 insertions, 0 deletions
diff --git a/scripts/ctrlroom/sydra-manager.sh b/scripts/ctrlroom/sydra-manager.sh
new file mode 100755
index 0000000..bd6c24b
--- /dev/null
+++ b/scripts/ctrlroom/sydra-manager.sh
@@ -0,0 +1,70 @@
+#!/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"
+MAIN_STAT_FILE="sydra-receiver.main"
+echo "00" > $MAIN_STAT_FILE
+
+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" > $MAIN_STAT_FILE
+ supervisorctl restart "$GROUP_NAME:main"
+ else
+ echo "unkown client: $arg" >&2
+ fi
+ NUM=''
+ ;;
+ reloadconfig)
+ kill -SIGHUP `cat supervisord.pid`
+ ;;
+ killall)
+ kill `cat supervisord.pid`
+ ;;
+ *)
+ echo "unkown command: $cmd" >&2
+ ;;
+ esac
+ fi
+done
+
+exit 0