#!/bin/sh

if [ -f app.pid ];then
    PID=$(cat app.pid)
    kill -12 $PID
    rm -f app.pid
fi


Server_Name=$(pwd|awk -F '["/"]' '{print $NF}')
if [ $Server_Name == "billing-private" ];then
	Server_Name="elottery-billing-pg2.jar"
elif [ $Server_Name == "billing-online" ];then
	Server_Name="elottery-billing-pg6.jar"
elif [ $Server_Name == "billing" ];then
	Server_Name="elottery-billing-pg.jar"
fi
	


PID_Number=$(jps -l|grep $Server_Name | awk  '{print $1}')
if [ -z "$PID_Number" ];then
        echo "Use kill -12 to Kill $Server_Name or Already Shutting Down $Server_Name！！"
        echo "Shutting down $Server_Name SUCCESS!"
else
        kill -9 $PID_Number
        echo "Use kill -9 to Kill $Server_Name"
        echo "Shutting down $Server_Name SUCCESS!"
fi

