idlize
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.js15warn() {16echo ""17echo -e "\033[1;33m`date '+[%Y-%m-%d %H:%M:%S]'`$@\033[0m"18}
19
20error() {21echo ""22echo -e "\033[1;31m`date '+[%Y-%m-%d %H:%M:%S]'`$@\033[0m"23}
24
25fail() {26error "$@"27exit 128}
29
30# Determine node to start hvigor wrapper script
31if [ -n "${NODE_HOME}" ];then32EXECUTABLE_NODE="${NODE_HOME}/bin/node"33if [ ! -x "$EXECUTABLE_NODE" ];then34fail "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"35fi36else
37EXECUTABLE_NODE="node"38which ${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" ];then43fail "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