From 94b3c74cdcb33fa010b84fc10d725fb1f29f9f06 Mon Sep 17 00:00:00 2001 From: Nishant Date: Fri, 24 Jun 2016 15:02:34 -0700 Subject: [PATCH] Druid launch script improvements (#3175) * Add status command to launch scripts * make druid init script to pick up config directories from environment variables make druid init script to pick up config directories from environment variables --- examples/bin/broker.sh | 2 +- examples/bin/coordinator.sh | 2 +- examples/bin/historical.sh | 2 +- examples/bin/middleManager.sh | 2 +- examples/bin/node.sh | 38 ++++++++++++++++++++++++++++------- examples/bin/overlord.sh | 2 +- 6 files changed, 36 insertions(+), 12 deletions(-) diff --git a/examples/bin/broker.sh b/examples/bin/broker.sh index d09f5710085..d67d450f59c 100644 --- a/examples/bin/broker.sh +++ b/examples/bin/broker.sh @@ -1,6 +1,6 @@ #!/bin/bash -eu -usage="Usage: broker.sh (start|stop)" +usage="Usage: broker.sh (start|stop|status)" if [ $# -lt 1 ]; then echo $usage diff --git a/examples/bin/coordinator.sh b/examples/bin/coordinator.sh index c266fc29c20..048fdd77092 100644 --- a/examples/bin/coordinator.sh +++ b/examples/bin/coordinator.sh @@ -1,6 +1,6 @@ #!/bin/bash -eu -usage="Usage: coordinator.sh (start|stop)" +usage="Usage: coordinator.sh (start|stop|status)" if [ $# -lt 1 ]; then echo $usage diff --git a/examples/bin/historical.sh b/examples/bin/historical.sh index fb7ebe630ca..ede1b18d92e 100644 --- a/examples/bin/historical.sh +++ b/examples/bin/historical.sh @@ -1,6 +1,6 @@ #!/bin/bash -eu -usage="Usage: historical.sh (start|stop)" +usage="Usage: historical.sh (start|stop|status)" if [ $# -lt 1 ]; then echo $usage diff --git a/examples/bin/middleManager.sh b/examples/bin/middleManager.sh index 53dfc6b50a9..00b85d16f50 100644 --- a/examples/bin/middleManager.sh +++ b/examples/bin/middleManager.sh @@ -1,6 +1,6 @@ #!/bin/bash -eu -usage="Usage: middleManager.sh (start|stop)" +usage="Usage: middleManager.sh (start|stop|status)" if [ $# -lt 1 ]; then echo $usage diff --git a/examples/bin/node.sh b/examples/bin/node.sh index a4b320d6abe..1e0671c31e9 100644 --- a/examples/bin/node.sh +++ b/examples/bin/node.sh @@ -1,9 +1,14 @@ #!/bin/bash -eu -## Initializtion script for druid nodes -## Runs druid nodes as a daemon and pipes logs to log/ directory +## Initialization script for druid nodes +## Runs druid nodes as a daemon +## Environment Variables used by this script - +## DRUID_LIB_DIR - directory having druid jar files, default=lib +## DRUID_CONF_DIR - directory having druid config files, default=conf/druid +## DRUID_LOG_DIR - directory used to store druid logs, default=log +## DRUID_PID_DIR - directory used to store pid files, default=var/druid/pids -usage="Usage: node.sh nodeType (start|stop)" +usage="Usage: node.sh nodeType (start|stop|status)" if [ $# -le 1 ]; then echo $usage @@ -13,10 +18,16 @@ fi nodeType=$1 shift -startStop=$1 -pid=var/druid/pids/$nodeType.pid +command=$1 -case $startStop in +LIB_DIR="${DRUID_LIB_DIR:=lib}" +CONF_DIR="${DRUID_CONF_DIR:=conf/druid}" +LOG_DIR="${DRUID_LOG_DIR:=log}" +PID_DIR="${DRUID_PID_DIR:=var/druid/pids}" + +pid=$PID_DIR/$nodeType.pid + +case $command in (start) @@ -27,7 +38,7 @@ case $startStop in fi fi - nohup java `cat conf/druid/$nodeType/jvm.config | xargs` -cp conf/druid/_common:conf/druid/$nodeType:lib/* io.druid.cli.Main server $nodeType > log/$nodeType.log & + nohup java `cat $CONF_DIR/$nodeType/jvm.config | xargs` -cp $CONF_DIR/_common:$CONF_DIR/$nodeType:$LIB_DIR/* io.druid.cli.Main server $nodeType > $LOG_DIR/$nodeType.log & nodeType_PID=$! echo $nodeType_PID > $pid echo "Started $nodeType node ($nodeType_PID)" @@ -49,6 +60,19 @@ case $startStop in fi ;; + (status) + if [ -f $pid ]; then + if kill -0 `cat $pid` > /dev/null 2>&1; then + echo RUNNING + exit 0 + else + echo STOPPED + fi + else + echo STOPPED + fi + ;; + (*) echo $usage exit 1 diff --git a/examples/bin/overlord.sh b/examples/bin/overlord.sh index c29cffc72f0..b26ee7b4c91 100644 --- a/examples/bin/overlord.sh +++ b/examples/bin/overlord.sh @@ -1,6 +1,6 @@ #!/bin/bash -eu -usage="Usage: overlord.sh (start|stop)" +usage="Usage: overlord.sh (start|stop|status)" if [ $# -lt 1 ]; then echo $usage