2019-03-29 18:30:03 +08:00
|
|
|
#!/bin/sh
|
2019-03-29 13:25:29 +08:00
|
|
|
|
2019-10-08 16:06:00 +08:00
|
|
|
usage="Usage: dolphinscheduler-daemon.sh (start|stop) <command> "
|
2019-03-29 13:25:29 +08:00
|
|
|
|
|
|
|
# if no args specified, show usage
|
|
|
|
if [ $# -le 1 ]; then
|
|
|
|
echo $usage
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
startStop=$1
|
|
|
|
shift
|
|
|
|
command=$1
|
|
|
|
shift
|
|
|
|
|
|
|
|
echo "Begin $startStop $command......"
|
|
|
|
|
|
|
|
BIN_DIR=`dirname $0`
|
|
|
|
BIN_DIR=`cd "$BIN_DIR"; pwd`
|
2019-10-08 16:06:00 +08:00
|
|
|
DOLPHINSCHEDULER_HOME=$BIN_DIR/..
|
2019-03-29 13:25:29 +08:00
|
|
|
|
|
|
|
export JAVA_HOME=$JAVA_HOME
|
|
|
|
#export JAVA_HOME=/opt/soft/jdk
|
|
|
|
export HOSTNAME=`hostname`
|
|
|
|
|
2019-10-08 16:06:00 +08:00
|
|
|
export DOLPHINSCHEDULER_PID_DIR=/tmp/
|
|
|
|
export DOLPHINSCHEDULER_LOG_DIR=$DOLPHINSCHEDULER_HOME/logs
|
|
|
|
export DOLPHINSCHEDULER_CONF_DIR=$DOLPHINSCHEDULER_HOME/conf
|
|
|
|
export DOLPHINSCHEDULER_LIB_JARS=$DOLPHINSCHEDULER_HOME/lib/*
|
2019-03-29 13:25:29 +08:00
|
|
|
|
2019-10-08 16:06:00 +08:00
|
|
|
export DOLPHINSCHEDULER_OPTS="-server -Xmx16g -Xms4g -Xss512k -XX:+DisableExplicitGC -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:LargePageSizeInBytes=128m -XX:+UseFastAccessorMethods -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70"
|
2019-03-29 13:25:29 +08:00
|
|
|
export STOP_TIMEOUT=5
|
|
|
|
|
2019-10-08 16:06:00 +08:00
|
|
|
if [ ! -d "$DOLPHINSCHEDULER_LOG_DIR" ]; then
|
|
|
|
mkdir $DOLPHINSCHEDULER_LOG_DIR
|
2019-03-29 13:25:29 +08:00
|
|
|
fi
|
|
|
|
|
2019-10-08 16:06:00 +08:00
|
|
|
log=$DOLPHINSCHEDULER_LOG_DIR/dolphinscheduler-$command-$HOSTNAME.out
|
|
|
|
pid=$DOLPHINSCHEDULER_LOG_DIR/dolphinscheduler-$command.pid
|
2019-03-29 13:25:29 +08:00
|
|
|
|
2019-10-08 16:06:00 +08:00
|
|
|
cd $DOLPHINSCHEDULER_HOME
|
2019-03-29 13:25:29 +08:00
|
|
|
|
|
|
|
if [ "$command" = "api-server" ]; then
|
|
|
|
LOG_FILE="-Dlogging.config=conf/apiserver_logback.xml"
|
2019-09-29 19:39:01 +08:00
|
|
|
CLASS=org.apache.dolphinscheduler.api.ApiApplicationServer
|
2019-03-29 13:25:29 +08:00
|
|
|
elif [ "$command" = "master-server" ]; then
|
2019-10-10 17:12:04 +08:00
|
|
|
LOG_FILE="-Dspring.profiles.active=master -Ddruid.mysql.usePingMethod=false"
|
2019-09-29 19:39:01 +08:00
|
|
|
CLASS=org.apache.dolphinscheduler.server.master.MasterServer
|
2019-03-29 13:25:29 +08:00
|
|
|
elif [ "$command" = "worker-server" ]; then
|
2019-10-10 17:12:04 +08:00
|
|
|
LOG_FILE="-Dspring.profiles.active=worker -Ddruid.mysql.usePingMethod=false"
|
2019-09-29 19:39:01 +08:00
|
|
|
CLASS=org.apache.dolphinscheduler.server.worker.WorkerServer
|
2019-03-29 13:25:29 +08:00
|
|
|
elif [ "$command" = "alert-server" ]; then
|
2019-10-10 17:12:04 +08:00
|
|
|
LOG_FILE="-Dspring.profiles.active=alert -Ddruid.mysql.usePingMethod=false"
|
2019-09-29 19:39:01 +08:00
|
|
|
CLASS=org.apache.dolphinscheduler.alert.AlertServer
|
2019-03-29 13:25:29 +08:00
|
|
|
elif [ "$command" = "logger-server" ]; then
|
2019-09-29 19:39:01 +08:00
|
|
|
CLASS=org.apache.dolphinscheduler.server.rpc.LoggerServer
|
2019-03-29 13:25:29 +08:00
|
|
|
else
|
|
|
|
echo "Error: No command named \`$command' was found."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
case $startStop in
|
|
|
|
(start)
|
2019-10-08 16:06:00 +08:00
|
|
|
[ -w "$DOLPHINSCHEDULER_PID_DIR" ] || mkdir -p "$DOLPHINSCHEDULER_PID_DIR"
|
2019-03-29 13:25:29 +08:00
|
|
|
|
|
|
|
if [ -f $pid ]; then
|
|
|
|
if kill -0 `cat $pid` > /dev/null 2>&1; then
|
|
|
|
echo $command running as process `cat $pid`. Stop it first.
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo starting $command, logging to $log
|
|
|
|
|
2019-10-08 16:06:00 +08:00
|
|
|
exec_command="$LOG_FILE $DOLPHINSCHEDULER_OPTS -classpath $DOLPHINSCHEDULER_CONF_DIR:$DOLPHINSCHEDULER_LIB_JARS $CLASS"
|
2019-03-29 13:25:29 +08:00
|
|
|
|
|
|
|
echo "nohup $JAVA_HOME/bin/java $exec_command > $log 2>&1 < /dev/null &"
|
|
|
|
nohup $JAVA_HOME/bin/java $exec_command > $log 2>&1 < /dev/null &
|
|
|
|
echo $! > $pid
|
|
|
|
;;
|
|
|
|
|
|
|
|
(stop)
|
|
|
|
|
|
|
|
if [ -f $pid ]; then
|
|
|
|
TARGET_PID=`cat $pid`
|
|
|
|
if kill -0 $TARGET_PID > /dev/null 2>&1; then
|
|
|
|
echo stopping $command
|
|
|
|
kill $TARGET_PID
|
|
|
|
sleep $STOP_TIMEOUT
|
|
|
|
if kill -0 $TARGET_PID > /dev/null 2>&1; then
|
|
|
|
echo "$command did not stop gracefully after $STOP_TIMEOUT seconds: killing with kill -9"
|
|
|
|
kill -9 $TARGET_PID
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo no $command to stop
|
|
|
|
fi
|
|
|
|
rm -f $pid
|
|
|
|
else
|
|
|
|
echo no $command to stop
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
|
|
|
|
(*)
|
|
|
|
echo $usage
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
|
|
|
|
esac
|
|
|
|
|
|
|
|
echo "End $startStop $command."
|