hue.sh 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #!/bin/bash
  2. # Licensed to Cloudera, Inc. under one
  3. # or more contributor license agreements. See the NOTICE file
  4. # distributed with this work for additional information
  5. # regarding copyright ownership. Cloudera, Inc. licenses this file
  6. # to you under the Apache License, Version 2.0 (the
  7. # "License"); you may not use this file except in compliance
  8. # with 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. # wrapper script to identify the latest python and pass the execution
  18. # to the corresponding hue script in the `build` directory.
  19. set -ex
  20. # Time marker for both stderr and stdout
  21. date; date 1>&2
  22. export SCRIPT_DIR=`dirname $0`
  23. export HUE_HOME_DIR=$(dirname $(dirname "$SCRIPT_DIR"))
  24. source $SCRIPT_DIR/python/python_helper.sh
  25. function stop_previous_hueprocs() {
  26. for p in $(cat /tmp/hue_${HUE_PORT}.pid); do
  27. if [[ $p -eq $(ps -p $p -ho pid=) ]]; then
  28. kill -9 $p
  29. fi
  30. done
  31. }
  32. PYTHON_BIN="${HUE_HOME_DIR}/$(latest_venv_bin_path)/python"
  33. HUE="${HUE_HOME_DIR}/$(latest_venv_bin_path)/hue"
  34. HUE_LOGLISTENER="${HUE_HOME_DIR}/desktop/core/src/desktop/loglistener.py"
  35. if [[ "dumpdata" == "$1" ]]; then
  36. umask 037
  37. "$HUE" "$1" --indent 2 > "$2"
  38. elif [[ "syncdb" == "$1" ]]; then
  39. run_syncdb_and_migrate_subcommands
  40. elif [[ "ldaptest" == "$1" ]]; then
  41. "$HUE" "$1"
  42. elif [[ "runcpserver" == "$1" ]]; then
  43. exec "$HUE" "runcpserver"
  44. elif [[ "rungunicornserver" == "$1" ]]; then
  45. stop_previous_hueprocs
  46. exec "$PYTHON_BIN" "$HUE_LOGLISTENER" &
  47. echo $! > /tmp/hue_${HUE_PORT}.pid
  48. exec "$HUE" "rungunicornserver"
  49. else
  50. exec "$HUE" "$@"
  51. fi