dolphin-daemon.sh.j2 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. #!/bin/sh
  2. #
  3. # Licensed to the Apache Software Foundation (ASF) under one or more
  4. # contributor license agreements. See the NOTICE file distributed with
  5. # this work for additional information regarding copyright ownership.
  6. # The ASF licenses this file to You under the Apache License, Version 2.0
  7. # (the "License"); you may not use this file except in compliance with
  8. # the License. You may obtain a copy of the License at
  9. #
  10. # http://www.apache.org/licenses/LICENSE-2.0
  11. #
  12. # Unless required by applicable law or agreed to in writing, software
  13. # distributed under the License is distributed on an "AS IS" BASIS,
  14. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. # See the License for the specific language governing permissions and
  16. # limitations under the License.
  17. #
  18. usage="Usage: dolphinscheduler-daemon.sh (start|stop) <command> "
  19. # if no args specified, show usage
  20. if [ $# -le 1 ]; then
  21. echo $usage
  22. exit 1
  23. fi
  24. startStop=$1
  25. shift
  26. command=$1
  27. shift
  28. echo "Begin $startStop $command......"
  29. BIN_DIR=`dirname $0`
  30. BIN_DIR=`cd "$BIN_DIR"; pwd`
  31. DOLPHINSCHEDULER_HOME=$BIN_DIR/..
  32. export HOSTNAME=`hostname`
  33. DOLPHINSCHEDULER_LIB_JARS={{dolphin_lib_jars}}
  34. DOLPHINSCHEDULER_OPTS="-server -Xmx16g -Xms1g -Xss512k -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:LargePageSizeInBytes=10m -XX:+UseFastAccessorMethods -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70"
  35. STOP_TIMEOUT=5
  36. log={{dolphin_log_dir}}/dolphinscheduler-$command-$HOSTNAME.out
  37. pid={{dolphin_pidfile_dir}}/$command.pid
  38. cd $DOLPHINSCHEDULER_HOME
  39. if [ "$command" = "api-server" ]; then
  40. LOG_FILE="-Dlogging.config={{dolphin_conf_dir}}/logback-api.xml -Dspring.profiles.active=api"
  41. CLASS=org.apache.dolphinscheduler.api.ApiApplicationServer
  42. elif [ "$command" = "master-server" ]; then
  43. LOG_FILE="-Dlogging.config={{dolphin_conf_dir}}/logback-master.xml -Ddruid.mysql.usePingMethod=false"
  44. CLASS=org.apache.dolphinscheduler.server.master.MasterServer
  45. elif [ "$command" = "worker-server" ]; then
  46. LOG_FILE="-Dlogging.config={{dolphin_conf_dir}}/logback-worker.xml -Ddruid.mysql.usePingMethod=false"
  47. CLASS=org.apache.dolphinscheduler.server.worker.WorkerServer
  48. elif [ "$command" = "alert-server" ]; then
  49. LOG_FILE="-Dlogging.config={{dolphin_conf_dir}}/logback-alert.xml"
  50. CLASS=org.apache.dolphinscheduler.alert.AlertServer
  51. elif [ "$command" = "logger-server" ]; then
  52. CLASS=org.apache.dolphinscheduler.server.log.LoggerServer
  53. else
  54. echo "Error: No command named \`$command' was found."
  55. exit 1
  56. fi
  57. case $startStop in
  58. (start)
  59. if [ -f $pid ]; then
  60. if kill -0 `cat $pid` > /dev/null 2>&1; then
  61. echo $command running as process `cat $pid`. Stop it first.
  62. exit 1
  63. fi
  64. fi
  65. echo starting $command, logging to $log
  66. exec_command="$LOG_FILE $DOLPHINSCHEDULER_OPTS -classpath {{dolphin_conf_dir}}:{{dolphin_lib_jars}} $CLASS"
  67. echo "nohup java $exec_command > $log 2>&1 < /dev/null &"
  68. nohup java $exec_command > $log 2>&1 < /dev/null &
  69. echo $! > $pid
  70. ;;
  71. (stop)
  72. if [ -f $pid ]; then
  73. TARGET_PID=`cat $pid`
  74. if kill -0 $TARGET_PID > /dev/null 2>&1; then
  75. echo stopping $command
  76. kill $TARGET_PID
  77. sleep $STOP_TIMEOUT
  78. if kill -0 $TARGET_PID > /dev/null 2>&1; then
  79. echo "$command did not stop gracefully after $STOP_TIMEOUT seconds: killing with kill -9"
  80. kill -9 $TARGET_PID
  81. fi
  82. else
  83. echo no $command to stop
  84. fi
  85. rm -f $pid
  86. else
  87. echo no $command to stop
  88. fi
  89. ;;
  90. (*)
  91. echo $usage
  92. exit 1
  93. ;;
  94. esac
  95. echo "End $startStop $command."