#!/bin/bash ############################ ROOT_D="$1" GROUP_NAME="$2" ############################ printUsage() { echo "Usage: $0 " } 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