jobmanager.sh 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #!/usr/bin/env bash
  2. ################################################################################
  3. # Licensed to the Apache Software Foundation (ASF) under one
  4. # or more contributor license agreements. See the NOTICE file
  5. # distributed with this work for additional information
  6. # regarding copyright ownership. The ASF licenses this file
  7. # to you under the Apache License, Version 2.0 (the
  8. # "License"); you may not use this file except in compliance
  9. # with the License. You may obtain a copy of the License at
  10. #
  11. # http://www.apache.org/licenses/LICENSE-2.0
  12. #
  13. # Unless required by applicable law or agreed to in writing, software
  14. # distributed under the License is distributed on an "AS IS" BASIS,
  15. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. # See the License for the specific language governing permissions and
  17. # limitations under the License.
  18. ################################################################################
  19. # Start/stop a Flink JobManager.
  20. USAGE="Usage: jobmanager.sh ((start|start-foreground) [args])|stop|stop-all"
  21. STARTSTOP=$1
  22. if [ -z $2 ] || [[ $2 == "-D" ]]; then
  23. # start [-D ...]
  24. args=("${@:2}")
  25. elif [ -z $3 ] || [[ $3 == "-D" ]]; then
  26. # legacy path: start <host> [-D ...]
  27. HOST=$2
  28. args=("${@:3}")
  29. else
  30. # legacy path: start <host> <port> [-D ...]
  31. HOST=$2
  32. WEBUIPORT=$3
  33. args=("${@:4}")
  34. fi
  35. if [[ $STARTSTOP != "start" ]] && [[ $STARTSTOP != "start-foreground" ]] && [[ $STARTSTOP != "stop" ]] && [[ $STARTSTOP != "stop-all" ]]; then
  36. echo $USAGE
  37. exit 1
  38. fi
  39. bin=`dirname "$0"`
  40. bin=`cd "$bin"; pwd`
  41. . "$bin"/config.sh
  42. ENTRYPOINT=standalonesession
  43. if [[ $STARTSTOP == "start" ]] || [[ $STARTSTOP == "start-foreground" ]]; then
  44. # Add JobManager-specific JVM options
  45. export FLINK_ENV_JAVA_OPTS="${FLINK_ENV_JAVA_OPTS} ${FLINK_ENV_JAVA_OPTS_JM}"
  46. parseJmArgsAndExportLogs "${args[@]}"
  47. args=("--configDir" "${FLINK_CONF_DIR}" "--executionMode" "cluster" "${args[@]}")
  48. if [ ! -z $HOST ]; then
  49. args+=("--host")
  50. args+=("${HOST}")
  51. fi
  52. if [ ! -z $WEBUIPORT ]; then
  53. args+=("--webui-port")
  54. args+=("${WEBUIPORT}")
  55. fi
  56. if [ ! -z "${DYNAMIC_PARAMETERS}" ]; then
  57. args=(${DYNAMIC_PARAMETERS[@]} "${args[@]}")
  58. fi
  59. fi
  60. if [[ $STARTSTOP == "start-foreground" ]]; then
  61. exec "${FLINK_BIN_DIR}"/flink-console.sh $ENTRYPOINT "${args[@]}"
  62. else
  63. "${FLINK_BIN_DIR}"/flink-daemon.sh $STARTSTOP $ENTRYPOINT "${args[@]}"
  64. fi