Skip to content

Instantly share code, notes, and snippets.

@pisceanfoot
Created September 8, 2015 02:56
Show Gist options
  • Save pisceanfoot/d641f839032e8ed39335 to your computer and use it in GitHub Desktop.
Save pisceanfoot/d641f839032e8ed39335 to your computer and use it in GitHub Desktop.
shell dir console color
#!/bin/sh
CURRENT_PATH=`dirname $0`
PORT="10002"
#LOG4JS_CONFIG="../config/logger.json"
PID_FILE="$CURRENT_PATH/../run/pid"
############################
# FUNCTION
############################
RES='\033[0m'
RED_COLOR='\033[47;31;1m'
GREEN_COLOR='\033[47;32;1m'
echo_success(){
echo "${GREEN_COLOR}$1${RES}"
}
echo_failure(){
echo "${RED_COLOR}$1${RES}"
}
############################
# END FUNCTION
############################
echo "###### Stat app #######"
if [ -n "$LOG4JS_CONFIG" ]; then
echo "Setting log config path: $CURRENT_PATH/$LOG4JS_CONFIG"
if [ -f $CURRENT_PATH/$LOG4JS_CONFIG ]; then
echo_success "Log config path: $CURRENT_PATH/$LOG4JS_CONFIG"
LOG4JS_CONFIG=$CURRENT_PATH/$LOG4JS_CONFIG
export LOG4JS_CONFIG
else
echo_failure "Log config file not found: $CURRENT_PATH/$LOG4JS_CONFIG"
fi
fi
if [ -n "$PORT" ]; then
echo_success "Listening on port: $PORT"
export PORT
fi
echo "$CURRENT_PATH/www"
nohup node "$CURRENT_PATH/www" > /dev/null 2>&1 & echo $! > $PID_FILE
echo "Running node on pid: $!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment