Created
January 16, 2018 09:12
-
-
Save unaipme/5296e02299f32c36d78bc553234c2406 to your computer and use it in GitHub Desktop.
Druid simple execution wrapper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
_LOG_DIR=/var/log/druid | |
_PID_DIR=/var/run/druid | |
function start { | |
if [ -f $_PID_DIR/$1.pid ]; then | |
echo "Component $1 already running" | |
else | |
if [ -f $_LOG_DIR/$1.out ]; then | |
mv $_LOG_DIR/$1.out "$_LOG_DIR/$1.out-$(date +%Y%m%d%H%M%S)" | |
fi | |
nohup java $(cat conf/druid/$1/jvm.config | xargs) -cp conf/druid/$1:conf/druid/_common:lib/* io.druid.cli.Main server $1 2> $_LOG_DIR/$1.out & | |
echo $! > $_PID_DIR/$1.pid | |
fi | |
} | |
function stop { | |
if [ ! -f $_PID_DIR/$1.pid ]; then | |
echo "Component $1 not running" | |
else | |
kill $(cat $_PID_DIR/$1.pid) | |
rm -f $_PID_DIR/$1.pid | |
fi | |
} | |
if [ $# -lt 1 ]; then | |
echo "Possible options: ./druid {start|stop} [COMPONENT1 [COMPONENT2...]]" | |
echo "Components: {broker|coordinator|historical|middleManager|overlord}" | |
exit 1 | |
fi | |
if [ "$1" != "start" ] && [ "$1" != "stop" ]; then | |
echo "Possible options: ./druid {start|stop} [COMPONENT1 [COMPONENT2...]]" | |
echo "Components: {broker|coordinator|historical|middleManager|overlord}" | |
exit 1 | |
fi | |
_MODE=$1 | |
shift | |
if [ "$#" == "0" ]; then | |
_CMP=("broker" "coordinator" "historical" "middleManager" "overlord") | |
for i in "${_CMP[@]}" | |
do | |
$_MODE $i | |
done | |
else | |
while [ "$1" != "" ]; do | |
$_MODE $1 | |
shift | |
done | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment