hue.sh 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #!/bin/bash
  2. # Copyright (c) 2019 Cloudera, Inc. All rights reserved.
  3. set -x
  4. # Time marker for both stderr and stdout
  5. date; date 1>&2
  6. export DESKTOP_LOG_DIR="/var/log/hive"
  7. export PYTHON_EGG_CACHE=$HUE_CONF_DIR/.python-eggs
  8. export SERVER_SOFTWARE="apache"
  9. function prepare_huedb() {
  10. $HUE_BIN/hue syncdb --noinput
  11. $HUE_BIN/hue makemigrations --noinput --merge
  12. $HUE_BIN/hue migrate
  13. }
  14. function db_connectivity_check() {
  15. i="0"
  16. ret="fail"
  17. # perform db connectivity check for 5 times
  18. while [[ $i -lt 5 ]]; do
  19. echo "Running db connectivity check"
  20. status=$(echo quit|$HUE_BIN/hue dbshell 2>&1|wc -l)
  21. # check if db connection is successful
  22. if [[ $status -gt 1 ]]; then
  23. ret="success"
  24. break
  25. fi
  26. sleep 1
  27. i=$[$i+1]
  28. echo "Failing db connectivity check: $i"
  29. done
  30. echo "$ret"
  31. }
  32. # If database connectivity is not set then fail
  33. ret=$(db_connectivity_check)
  34. if [[ $ret == "fail" ]]; then
  35. exit 1
  36. fi
  37. # prepare db schema
  38. prepare_huedb
  39. if [[ $1 == kt_renewer ]]; then
  40. if [ -e "/etc/hue/conf/kerberos.ini" ]; then
  41. # The Kerberos ticket renewer role needs to know where kinit is.
  42. KINIT_PATH=`which kinit`
  43. KINIT_PATH=${KINIT_PATH-/usr/bin/kinit}
  44. $HUE_BIN/hue kt_renewer
  45. fi
  46. elif [[ $1 == runcpserver ]]; then
  47. $HUE_BIN/hue runcherrypyserver
  48. fi
  49. exit 0