From 0bf00036c64669862e6aa79c31aa530dd1857eda Mon Sep 17 00:00:00 2001 From: Andreas Streichardt Date: Wed, 29 Mar 2017 11:48:55 +0200 Subject: [PATCH] Streamline shutdown and start --- scripts/cluster-run-common.sh | 116 ++++++++++++++++++++++++++++++++ scripts/shutdownLocalCluster.sh | 36 ++-------- scripts/startLocalCluster.sh | 115 +------------------------------ 3 files changed, 121 insertions(+), 146 deletions(-) create mode 100644 scripts/cluster-run-common.sh diff --git a/scripts/cluster-run-common.sh b/scripts/cluster-run-common.sh new file mode 100644 index 0000000000..7480890fea --- /dev/null +++ b/scripts/cluster-run-common.sh @@ -0,0 +1,116 @@ +#!/bin/bash + +function help() { + echo "USAGE: $0 [options]" + echo "" + echo "OPTIONS:" + echo " -a/--nagents # agents (odd integer default: 1))" + echo " -c/--ncoordinators # coordinators (odd integer default: 1))" + echo " -d/--ndbservers # db servers (odd integer default: 2))" + echo " -s/--secondaries Start secondaries (0|1 default: 0)" + echo " -t/--transport Protocol (ssl|tcp default: tcp)" + echo " -j/--jwt-secret JWT-Secret (string default: )" + echo " --log-level-agency Log level (agency) (string default: )" + echo " --log-level-cluster Log level (cluster) (string default: )" + echo " -i/--interactive Interactive mode (C|D|R default: '')" + echo " -x/--xterm XTerm command (default: xterm)" + echo " -o/--xterm-options XTerm options (default: --geometry=80x43)" + echo " -b/--offset-ports Offset ports (default: 0, i.e. A:4001, C:8530, D:8629)" + echo "" + echo "EXAMPLES:" + echo " $0" + echo " $0 -a 1 -c 1 -d 3 -t ssl" + echo " $0 -a 3 -c 1 -d 2 -t tcp -i C" + +} + +# defaults +NRAGENTS=1 +NRDBSERVERS=2 +NRCOORDINATORS=1 +POOLSZ="" +TRANSPORT="tcp" +LOG_LEVEL="INFO" +LOG_LEVEL_AGENCY="" +LOG_LEVEL_CLUSTER="" +if [ -z "$XTERM" ] ; then + XTERM="x-terminal-emulator" +fi +if [ -z "$XTERMOPTIONS" ] ; then + XTERMOPTIONS="--geometry=80x43" +fi +SECONDARIES=0 +BUILD="build" +JWT_SECRET="" +PORT_OFFSET=0 + +while [[ ${1} ]]; do + case "${1}" in + -a|--agency-size) + NRAGENTS=${2} + shift + ;; + -c|--ncoordinators) + NRCOORDINATORS=${2} + shift + ;; + -d|--ndbservers) + NRDBSERVERS=${2} + shift + ;; + -s|--secondaries) + SECONDARIES=${2} + shift + ;; + -t|--transport) + TRANSPORT=${2} + shift + ;; + --log-level-agency) + LOG_LEVEL_AGENCY=${2} + shift + ;; + --log-level-cluster) + LOG_LEVEL_CLUSTER=${2} + shift + ;; + -i|--interactive) + INTERACTIVE_MODE=${2} + shift + ;; + -j|--jwt-secret) + JWT_SECRET=${2} + shift + ;; + -x|--xterm) + XTERM=${2} + shift + ;; + -o|--xterm-options) + XTERMOPTIONS=${2} + shift + ;; + -b|--port-offset) + PORT_OFFSET=${2} + shift + ;; + -h|--help) + help + exit 1 + ;; + -B|--build) + BUILD=${2} + shift + ;; + *) + echo "Unknown parameter: ${1}" >&2 + help + exit 1 + ;; + esac + + if ! shift; then + echo 'Missing parameter argument.' >&2 + return 1 + fi +done \ No newline at end of file diff --git a/scripts/shutdownLocalCluster.sh b/scripts/shutdownLocalCluster.sh index 11e70b01d5..4b26e0f680 100755 --- a/scripts/shutdownLocalCluster.sh +++ b/scripts/shutdownLocalCluster.sh @@ -1,39 +1,11 @@ #!/bin/bash -NRAGENTS=$1 -if [ "$NRAGENTS" == "" ] ; then - NRAGENTS=1 -fi -if [[ $(( $NRAGENTS % 2 )) == 0 ]]; then - echo Number of agents must be odd. - exit 1 -fi + +. `dirname $0`/cluster-run-common.sh + echo Number of Agents: $NRAGENTS -NRDBSERVERS=$2 -if [ "$NRDBSERVERS" == "" ] ; then - NRDBSERVERS=2 -fi echo Number of DBServers: $NRDBSERVERS -NRCOORDINATORS=$3 -if [ "$NRCOORDINATORS" == "" ] ; then - NRCOORDINATORS=1 -fi echo Number of Coordinators: $NRCOORDINATORS -if [ ! -z "$4" ] ; then - if [ "$4" == "C" ] ; then - COORDINATORCONSOLE=1 - echo Starting one coordinator in terminal with --console - elif [ "$4" == "D" ] ; then - CLUSTERDEBUGGER=1 - echo Running cluster in debugger. - elif [ "$4" == "R" ] ; then - RRDEBUGGER=1 - echo Running cluster in rr with --console. - fi -fi - -SECONDARIES="$5" - shutdown() { PORT=$1 echo -n "$PORT " @@ -41,7 +13,7 @@ shutdown() { echo } -if [ -n "$SECONDARIES" ]; then +if [ "$SECONDARIES" == "1" ]; then echo "Shutting down secondaries..." PORTTOPSE=`expr 8729 + $NRDBSERVERS - 1` for PORT in `seq 8729 $PORTTOPSE` ; do diff --git a/scripts/startLocalCluster.sh b/scripts/startLocalCluster.sh index 9927d95d78..354080b79c 100755 --- a/scripts/startLocalCluster.sh +++ b/scripts/startLocalCluster.sh @@ -1,119 +1,6 @@ #!/bin/bash -function help() { - echo "USAGE: scripts/startLocalCluster.sh [options]" - echo "" - echo "OPTIONS:" - echo " -a/--nagents # agents (odd integer default: 1))" - echo " -c/--ncoordinators # coordinators (odd integer default: 1))" - echo " -d/--ndbservers # db servers (odd integer default: 2))" - echo " -s/--secondaries Start secondaries (0|1 default: 0)" - echo " -t/--transport Protocol (ssl|tcp default: tcp)" - echo " -j/--jwt-secret JWT-Secret (string default: )" - echo " --log-level-agency Log level (agency) (string default: )" - echo " --log-level-cluster Log level (cluster) (string default: )" - echo " -i/--interactive Interactive mode (C|D|R default: '')" - echo " -x/--xterm XTerm command (default: xterm)" - echo " -o/--xterm-options XTerm options (default: --geometry=80x43)" - echo " -b/--offset-ports Offset ports (default: 0, i.e. A:4001, C:8530, D:8629)" - echo "" - echo "EXAMPLES:" - echo " scripts/startLocalCluster.sh" - echo " scripts/startLocalCluster.sh -a 1 -c 1 -d 3 -t ssl" - echo " scripts/startLocalCluster.sh -a 3 -c 1 -d 2 -t tcp -i C" - -} - -# defaults -NRAGENTS=1 -NRDBSERVERS=2 -NRCOORDINATORS=1 -POOLSZ="" -TRANSPORT="tcp" -LOG_LEVEL="INFO" -LOG_LEVEL_AGENCY="" -LOG_LEVEL_CLUSTER="" -if [ -z "$XTERM" ] ; then - XTERM="x-terminal-emulator" -fi -if [ -z "$XTERMOPTIONS" ] ; then - XTERMOPTIONS="--geometry=80x43" -fi -SECONDARIES=0 -BUILD="build" -JWT_SECRET="" -PORT_OFFSET=0 - -while [[ ${1} ]]; do - case "${1}" in - -a|--agency-size) - NRAGENTS=${2} - shift - ;; - -c|--ncoordinators) - NRCOORDINATORS=${2} - shift - ;; - -d|--ndbservers) - NRDBSERVERS=${2} - shift - ;; - -s|--secondaries) - SECONDARIES=${2} - shift - ;; - -t|--transport) - TRANSPORT=${2} - shift - ;; - --log-level-agency) - LOG_LEVEL_AGENCY=${2} - shift - ;; - --log-level-cluster) - LOG_LEVEL_CLUSTER=${2} - shift - ;; - -i|--interactive) - INTERACTIVE_MODE=${2} - shift - ;; - -j|--jwt-secret) - JWT_SECRET=${2} - shift - ;; - -x|--xterm) - XTERM=${2} - shift - ;; - -o|--xterm-options) - XTERMOPTIONS=${2} - shift - ;; - -b|--port-offset) - PORT_OFFSET=${2} - shift - ;; - -h|--help) - help - exit 1 - ;; - -B|--build) - BUILD=${2} - shift - ;; - *) - echo "Unknown parameter: ${1}" >&2 - help - exit 1 - ;; - esac - - if ! shift; then - echo 'Missing parameter argument.' >&2 - return 1 - fi -done +. `dirname $0`/cluster-run-common.sh if [ "$POOLSZ" == "" ] ; then POOLSZ=$NRAGENTS