#! /bin/sh
PORT="@profiles.server.port@"
BASEDIR=`dirname $0`
BASEDIR=`(cd "$BASEDIR"; pwd)`
PROJECT_NAME="@project.artifactId@"
MAIN_CLASS="$PROJECT_NAME";
SHELL_NAME="shutdown"
CDATE=$(date "+%Y-%m-%d")
CTIME=$(date "+%H:%M:%S")

#写日志
writelog() {
  LOGINFO=$1
  echo "${CDATE} ${CTIME}: ${SHELL_NAME} : ${LOGINFO}" >>${SHELL_LOG}
  echo ${LOGINFO}
}

if [ ! -n "$PORT" ]; then  
	writelog $"Usage: $0 {port}"
	exit $FAIL
fi


pid=`ps ax | grep -i "$MAIN_CLASS"  | grep java | grep -v grep | awk '{print $1}'`
if [ -z "$pid" ] ; then
        echo "No Server running."
        exit 9;
fi

writelog "stoping application $PROJECT_NAME......"

kill -15 ${pid}

writelog "Send shutdown request to Server $PROJECT_NAME OK"


