更新服务
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
#!/bin/bash
|
||||
|
||||
|
||||
# 路径
|
||||
HOME=$(cd $(dirname $0);pwd)
|
||||
|
||||
# 启动
|
||||
start(){
|
||||
cd $HOME
|
||||
# 将C++程序后台启动,并将启动日志指向springBootThree-1.0.log中
|
||||
spid=$(pgrep -f "controlServer") #$(ps -ef | grep "[m]controlServer" | grep -v grep | awk '{print $2}')
|
||||
if [ -z "$spid" ]
|
||||
then
|
||||
./controlServer > /dev/null 2>&1 &
|
||||
# 打印字符串
|
||||
echo "启动成功"
|
||||
else
|
||||
echo Application is already started
|
||||
fi
|
||||
}
|
||||
|
||||
# 停止
|
||||
stop(){
|
||||
# 查询到项目的pid
|
||||
tpid=$(pgrep -f "controlServer") #$(ps -ef | grep "[m]controlServer" | grep -v grep | awk '{print $2}')
|
||||
# 判断是否为空
|
||||
if [ -z "$tpid" ]
|
||||
then
|
||||
# 如果为空 则打印这句话
|
||||
echo Application is already stoped
|
||||
else
|
||||
# 如果不为空则执行
|
||||
echo kill $tpid
|
||||
# 关闭进程
|
||||
kill -9 $tpid
|
||||
|
||||
echo "程序已关闭"
|
||||
fi
|
||||
}
|
||||
|
||||
# 查看状态
|
||||
status(){
|
||||
# 获取pid的
|
||||
pid=$(pgrep -f "controlServer") #$(ps -ef | grep "[m]controlServer" | grep -v grep)
|
||||
if [ -z "$pid" ]
|
||||
then
|
||||
echo "程序不存在"
|
||||
else
|
||||
echo $pid
|
||||
fi
|
||||
}
|
||||
|
||||
# 查看日志信息
|
||||
log(){
|
||||
tail -f $HOME/CSPServer.log
|
||||
}
|
||||
|
||||
case $1 in
|
||||
start)
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
status)
|
||||
status
|
||||
;;
|
||||
log)
|
||||
log
|
||||
;;
|
||||
restart)
|
||||
$0 stop
|
||||
sleep 5
|
||||
$0 start
|
||||
;;
|
||||
*)
|
||||
echo "只能是{start|stop|log|restart}"
|
||||
;;
|
||||
esac
|
||||
exit 0
|
||||
Reference in New Issue
Block a user