#! /bin/bash

APP_ROOT_DIR=/home/gmt/app
NAME_SERVICE=EyeAPN_AsdeRecv
NAME_JAR=EyeAPN_AsdeRecv.jar
NAME_PID=./application.pid

PATH_EXE_ROOT=$APP_ROOT_DIR/$NAME_SERVICE
PATH_EXE_JAR=$PATH_EXE_ROOT/$NAME_JAR

PATH_CONFIG=$PATH_EXE_ROOT/cfg

OPT_JAVA="-Dfile.encoding=UTF-8 -Dlogging.config=$PATH_TO_CONFIG/logback-spring.xml"
OPT_SPRING="--spring.config.location=file:$PATH_CONFIG/application.yml"


cd $PATH_EXE_ROOT

echo java -jar $OPT_JAVA $PATH_EXE_JAR $OPT_SPRING

echo "Starting $NAME_SERVICE ..."
if [ ! -f $NAME_PID ]; then
	nohup java -jar $OPT_JAVA $PATH_EXE_JAR $OPT_SPRING >> /dev/null &
				echo $! > $PATH_EXE_ROOT/$NAME_PID
	echo "$NAME_SERVICE started ..."
else
	echo "$NAME_SERVICE is already running ..."
fi
exit 0
