2019-01-03 17:43:53 +08:00
|
|
|
#!/bin/bash
|
|
|
|
|
2019-01-04 15:54:19 +08:00
|
|
|
Tag="JpomApplication"
|
2019-02-13 10:58:09 +08:00
|
|
|
MainClass="cn.keepbx.jpom.JpomApplication"
|
2019-02-22 12:07:20 +08:00
|
|
|
# 自动获取当前路径
|
|
|
|
Path=$(cd `dirname $0`; pwd)"/"
|
2019-01-03 17:43:53 +08:00
|
|
|
Lib=${Path}"lib/"
|
|
|
|
Log=${Path}"run.log"
|
|
|
|
LogBack=${Path}"log/"
|
|
|
|
JVM="-server "
|
2019-02-22 12:07:20 +08:00
|
|
|
# 修改项目端口号
|
|
|
|
ARGS="--server.port=2122 --jpom.path="${Path}
|
2019-01-03 17:43:53 +08:00
|
|
|
|
|
|
|
echo ${Tag}
|
|
|
|
RETVAL="0"
|
|
|
|
|
2019-02-22 12:07:20 +08:00
|
|
|
# 启动程序
|
2019-01-03 17:43:53 +08:00
|
|
|
function start() {
|
|
|
|
echo ${Log}
|
2019-02-22 12:07:20 +08:00
|
|
|
# 备份日志
|
2019-01-03 17:43:53 +08:00
|
|
|
if [[ -f ${Log} ]]; then
|
|
|
|
if [[ ! -d ${LogBack} ]];then
|
|
|
|
mkdir ${LogBack}
|
|
|
|
fi
|
|
|
|
cur_dateTime="`date +%Y-%m-%d_%H:%M:%S`.log"
|
|
|
|
mv ${Log} ${LogBack}${cur_dateTime}
|
|
|
|
echo "mv to $LogBack$cur_dateTime"
|
|
|
|
touch ${Log}
|
|
|
|
fi
|
|
|
|
nohup java ${JVM} -Dappliction=$Tag -Djava.ext.dirs=${Lib}":${JAVA_HOME}/jre/lib/ext" ${MainClass} ${ARGS} > ${Log} 2>&1 &
|
|
|
|
tailf ${Log}
|
|
|
|
}
|
|
|
|
|
2019-02-22 12:07:20 +08:00
|
|
|
# 停止程序
|
2019-01-03 17:43:53 +08:00
|
|
|
function stop() {
|
|
|
|
pid=$(ps -ef | grep -v 'grep' | egrep $Tag| awk '{printf $2 " "}')
|
|
|
|
if [[ "$pid" != "" ]]; then
|
|
|
|
echo -n "boot ( pid $pid) is running"
|
|
|
|
echo
|
|
|
|
echo -n $"Shutting down boot: "
|
|
|
|
pid=$(ps -ef | grep -v 'grep' | egrep $Tag| awk '{printf $2 " "}')
|
|
|
|
if [[ "$pid" != "" ]]; then
|
|
|
|
echo "kill boot process"
|
|
|
|
kill -9 "$pid"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "boot is stopped"
|
|
|
|
fi
|
|
|
|
|
|
|
|
status
|
|
|
|
}
|
|
|
|
|
2019-02-22 12:07:20 +08:00
|
|
|
# 获取程序状态
|
2019-01-03 17:43:53 +08:00
|
|
|
function status()
|
|
|
|
{
|
|
|
|
pid=$(ps -ef | grep -v 'grep' | egrep ${Tag}| awk '{printf $2 " "}')
|
|
|
|
#echo "$pid"
|
|
|
|
if [[ "$pid" != "" ]]; then
|
|
|
|
echo "boot is running,pid is $pid"
|
|
|
|
else
|
|
|
|
echo "boot is stopped"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2019-02-22 12:07:20 +08:00
|
|
|
# 提示使用语法
|
2019-01-03 17:43:53 +08:00
|
|
|
function usage()
|
|
|
|
{
|
|
|
|
echo "Usage: $0 {start|stop|restart|status}"
|
|
|
|
RETVAL="2"
|
|
|
|
}
|
|
|
|
|
|
|
|
# See how we were called.
|
|
|
|
RETVAL="0"
|
|
|
|
case "$1" in
|
|
|
|
start)
|
|
|
|
start
|
|
|
|
;;
|
|
|
|
stop)
|
|
|
|
stop
|
|
|
|
;;
|
|
|
|
restart)
|
|
|
|
stop
|
|
|
|
start
|
|
|
|
;;
|
|
|
|
reload)
|
|
|
|
RETVAL="3"
|
|
|
|
;;
|
|
|
|
status)
|
|
|
|
status
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
usage
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
exit $RETVAL
|