Skip to content

Commit

Permalink
Adds init scripts (apache#2939)
Browse files Browse the repository at this point in the history
  • Loading branch information
Walton Seymour authored and fjy committed May 10, 2016
1 parent 45b2e65 commit 13a2b26
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 0 deletions.
10 changes: 10 additions & 0 deletions examples/bin/broker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash -eu

usage="Usage: broker.sh (start|stop)"

if [ $# -lt 1 ]; then
echo $usage
exit 1
fi

sh ./bin/node.sh broker $1
10 changes: 10 additions & 0 deletions examples/bin/coordinator.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash -eu

usage="Usage: coordinator.sh (start|stop)"

if [ $# -lt 1 ]; then
echo $usage
exit 1
fi

sh ./bin/node.sh coordinator $1
10 changes: 10 additions & 0 deletions examples/bin/historical.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash -eu

usage="Usage: historical.sh (start|stop)"

if [ $# -lt 1 ]; then
echo $usage
exit 1
fi

sh ./bin/node.sh historical $1
2 changes: 2 additions & 0 deletions examples/bin/init
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ gzip -c -d quickstart/wikiticker-2015-09-12-sampled.json.gz > "quickstart/wikiti

LOG_DIR=var

mkdir log
mkdir -p $LOG_DIR/tmp;
mkdir -p $LOG_DIR/druid/indexing-logs;
mkdir -p $LOG_DIR/druid/segments;
mkdir -p $LOG_DIR/druid/segment-cache;
mkdir -p $LOG_DIR/druid/task;
mkdir -p $LOG_DIR/druid/hadoop-tmp;
mkdir -p $LOG_DIR/druid/pids;
10 changes: 10 additions & 0 deletions examples/bin/middleManager.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash -eu

usage="Usage: middleManager.sh (start|stop)"

if [ $# -lt 1 ]; then
echo $usage
exit 1
fi

sh ./bin/node.sh middleManager $1
56 changes: 56 additions & 0 deletions examples/bin/node.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/bin/bash -eu

## Initializtion script for druid nodes
## Runs druid nodes as a daemon and pipes logs to log/ directory

usage="Usage: node.sh nodeType (start|stop)"

if [ $# -le 1 ]; then
echo $usage
exit 1
fi

nodeType=$1
shift

startStop=$1
pid=var/druid/pids/$nodeType.pid

case $startStop in

(start)

if [ -f $pid ]; then
if kill -0 `cat $pid` > /dev/null 2>&1; then
echo $nodeType node running as process `cat $pid`. Stop it first.
exit 1
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 &
nodeType_PID=$!
echo $nodeType_PID > $pid
echo "Started $nodeType node ($nodeType_PID)"
;;

(stop)

if [ -f $pid ]; then
TARGET_PID=`cat $pid`
if kill -0 $TARGET_PID > /dev/null 2>&1; then
echo Stopping process `cat $pid`...
kill $TARGET_PID
else
echo No $nodeType node to stop
fi
rm -f $pid
else
echo No $nodeType node to stop
fi
;;

(*)
echo $usage
exit 1
;;
esac
10 changes: 10 additions & 0 deletions examples/bin/overlord.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash -eu

usage="Usage: overlord.sh (start|stop)"

if [ $# -lt 1 ]; then
echo $usage
exit 1
fi

sh ./bin/node.sh overlord $1

0 comments on commit 13a2b26

Please sign in to comment.