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