hvigorw 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #!/bin/bash
  2. # ----------------------------------------------------------------------------
  3. # Hvigor startup script, version 1.0.0
  4. #
  5. # Required ENV vars:
  6. # ------------------
  7. # NODE_HOME - location of a Node home dir
  8. # or
  9. # Add /usr/local/nodejs/bin to the PATH environment variable
  10. # ----------------------------------------------------------------------------
  11. HVIGOR_APP_HOME=$(dirname $(readlink -f $0))
  12. HVIGOR_WRAPPER_SCRIPT=${HVIGOR_APP_HOME}/hvigor/hvigor-wrapper.js
  13. warn() {
  14. echo ""
  15. echo -e "\033[1;33m`date '+[%Y-%m-%d %H:%M:%S]'`$@\033[0m"
  16. }
  17. error() {
  18. echo ""
  19. echo -e "\033[1;31m`date '+[%Y-%m-%d %H:%M:%S]'`$@\033[0m"
  20. }
  21. fail() {
  22. error "$@"
  23. exit 1
  24. }
  25. # Determine node to start hvigor wrapper script
  26. if [ -n "${NODE_HOME}" ];then
  27. EXECUTABLE_NODE="${NODE_HOME}/bin/node"
  28. if [ ! -x "$EXECUTABLE_NODE" ];then
  29. fail "ERROR: NODE_HOME is set to an invalid directory,check $NODE_HOME\n\nPlease set NODE_HOME in your environment to the location where your nodejs installed"
  30. fi
  31. else
  32. EXECUTABLE_NODE="node"
  33. which ${EXECUTABLE_NODE} > /dev/null 2>&1 || fail "ERROR: NODE_HOME is not set and not 'node' command found in your path"
  34. fi
  35. # Check hvigor wrapper script
  36. if [ ! -r "$HVIGOR_WRAPPER_SCRIPT" ];then
  37. fail "ERROR: Couldn't find hvigor/hvigor-wrapper.js in ${HVIGOR_APP_HOME}"
  38. fi
  39. # start hvigor-wrapper script
  40. exec "${EXECUTABLE_NODE}" \
  41. "${HVIGOR_WRAPPER_SCRIPT}" "$@"