#!/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服务 重启脚本
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
推荐阅读更多精彩内容
- 来自底层程序员的仰望 6小时前 · 浙江汉朔电子科技公司北京分公司Java工程师 优质科技领域创作者 开头说几句 ...
- 将脚本保存为autorestart.sh脚本文件,使用chmod +x autorestart.sh给予执行权限 ...
- 每次手动重启一个服务至少要敲4行命令,有时手残输错一个字母或者数字又要重新输入,非常浪费感情,消磨耐性,尤其对于我...