go服务 重启脚本
作者:
Super淳语 | 来源:发表于
2021-12-15 19:33 被阅读0次
#!/bin/bash
echo "------------$(date +%F' '%T)------------"
# 开发重启脚本
file=material-mis
getPid() {
docmd=$(ps aux | grep ${file} | grep ${file} | grep -v 'grep' | grep -v '\.sh' | awk '{print $2}')
echo $docmd
}
start() {
pidstr=$(getPid)
if [ -n "$pidstr" ]; then
echo "running with pids $pidstr"
else
rm -rf material-mis
echo "正在编译中..."
go build
sleep 0.5
printf "\n"
printf "正在执行启动...稍候"
printf "\n"
nohup ./material-mis >/dev/null 2>&1 &
pidstr=$(getPid)
echo "start with pids $pidstr Successful"
fi
}
stop() {
pidstr=$(getPid)
if [ ! -n "$pidstr" ]; then
echo "Not Executed!"
return
fi
echo "kill $pidstr done"
kill $pidstr
}
restart() {
stop
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
getpid)
getPid
;;
esac
本文标题:go服务 重启脚本
本文链接:https://www.haomeiwen.com/subject/rfbpfrtx.html
网友评论