DRILL-639: Adding status command to DrillBit daemon Currently we have only start,stop, restart commands for Drillbit daemon. Adding status command to DrillBit daemon.
Project: http://git-wip-us.apache.org/repos/asf/incubator-drill/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-drill/commit/793a00d9 Tree: http://git-wip-us.apache.org/repos/asf/incubator-drill/tree/793a00d9 Diff: http://git-wip-us.apache.org/repos/asf/incubator-drill/diff/793a00d9 Branch: refs/heads/master Commit: 793a00d96f361762e5e8084f831597ee5cfef578 Parents: 3fb8fb6 Author: Pradeep Chanumolu <[email protected]> Authored: Mon May 5 13:43:31 2014 -0700 Committer: Jacques Nadeau <[email protected]> Committed: Tue May 6 09:19:58 2014 -0700 ---------------------------------------------------------------------- distribution/src/resources/drillbit.sh | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/793a00d9/distribution/src/resources/drillbit.sh ---------------------------------------------------------------------- diff --git a/distribution/src/resources/drillbit.sh b/distribution/src/resources/drillbit.sh index f5293a6..3bd0126 100755 --- a/distribution/src/resources/drillbit.sh +++ b/distribution/src/resources/drillbit.sh @@ -33,7 +33,7 @@ # Modelled after $HADOOP_HOME/bin/hadoop-daemon.sh usage="Usage: drillbit.sh [--config <conf-dir>]\ - (start|stop|restart|autorestart)" + (start|stop|status|restart|autorestart)" # if no args specified, show usage if [ $# -lt 1 ]; then @@ -47,7 +47,7 @@ bin=`cd "$bin">/dev/null; pwd` . "$bin"/drill-config.sh # get arguments -startStop=$1 +startStopStatus=$1 shift command=drillbit @@ -169,7 +169,7 @@ fi thiscmd=$0 args=$@ -case $startStop in +case $startStopStatus in (start) check_before_start @@ -223,6 +223,23 @@ case $startStop in wait_until_done $! ;; +(status) + + if [ -f $pid ]; then + TARGET_PID=`cat $pid` + if kill -0 $TARGET_PID > /dev/null 2>&1; then + echo $command is running. + exit 0 + else + echo $pid file is present but $command not running. + exit 1 + fi + else + echo $command not running. + exit 2 + fi + ;; + (*) echo $usage exit 1
