halo/bin/halo.sh

69 lines
1.0 KiB
Bash
Raw Normal View History

2018-01-21 10:08:26 +00:00
#!/bin/bash
2018-05-29 09:30:50 +00:00
APP_NAME=halo-latest.jar
2018-01-21 10:08:26 +00:00
usage() {
2018-03-19 01:52:30 +00:00
echo "用法: sh halo.sh [start(启动)|stop(停止)|restart(重启)|status(状态)]"
2018-01-21 10:08:26 +00:00
exit 1
}
is_exist(){
pid=`ps -ef|grep $APP_NAME|grep -v grep|awk '{print $2}' `
if [ -z "${pid}" ]; then
return 1
else
return 0
fi
}
start(){
is_exist
if [ $? -eq "0" ]; then
2018-03-19 01:52:30 +00:00
echo "${APP_NAME} 正在运行。 pid=${pid} ."
2018-01-21 10:08:26 +00:00
else
nohup java -server -Xms256m -Xmx512m -jar $APP_NAME > /dev/null 2>&1 &
2018-03-19 01:52:30 +00:00
echo "${APP_NAME}启动成功,请查看日志确保运行正常。"
2018-01-21 10:08:26 +00:00
fi
}
stop(){
is_exist
if [ $? -eq "0" ]; then
kill -9 $pid
2018-03-19 01:52:30 +00:00
echo "${pid} 进程已被杀死,程序停止运行"
2018-01-21 10:08:26 +00:00
else
2018-03-19 01:52:30 +00:00
echo "${APP_NAME} 没有运行。"
2018-01-21 10:08:26 +00:00
fi
}
status(){
is_exist
if [ $? -eq "0" ]; then
2018-03-19 01:52:30 +00:00
echo "${APP_NAME} 正在运行。Pid is ${pid}"
2018-01-21 10:08:26 +00:00
else
2018-03-19 01:52:30 +00:00
echo "${APP_NAME} 没有运行。"
2018-01-21 10:08:26 +00:00
fi
}
restart(){
stop
start
}
case "$1" in
"start")
start
;;
"stop")
stop
;;
"status")
status
;;
"restart")
restart
;;
*)
usage
;;
2018-04-03 10:00:51 +00:00
esac