#!/bin/sh
export LANG="en_US.UTF-8"
export JAVA_HOME=/opt/java8
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
##修改如下内容
export JAR_NAME=server.jar
export JAR_PATH=/opt/server
export JAR_HOME=$JAR_PATH/$JAR_NAME
export JAR_ENV=dev
export LOG_PATH=$JAR_PATH/logs/server.log
echo '==========开始启动==========='
pid=`ps -ef | grep $JAR_HOME | grep -v grep |gawk '{print $2}'`
if test $pid
then
echo '==========原始pid==========='$pid
echo `kill -9 $pid`
echo '==========进程清理完毕==========='
fi
echo '==========启动中=========='
echo `nohup java -Dloader.path=$JAR_PATH/lib -jar $JAR_HOME --spring.profiles.active=$JAR_ENV >$LOG_PATH 2>&1 &`
newpid=`ps -ef | grep $JAR_HOME | grep -v grep | awk '{print $2}'`
if test $newpid
then
echo '==========启动成功=========='$newpid
exit 0
else
echo '==========启动失败,请检查=========='
exit 1
fi