go项目 shell脚启动服务
作者:互联网
-
go 项目服务可重复启动脚本呢
#!/usr/bin/env bash # 启动服务检查 服务名 wyiwServer echo "*************wyiwServer start check*******************" # 输出服务名wyiwServer 的进程信息 ps -aux |grep wyiwServer # 获取服务wyiwServer 的pid信息 赋值给变量 serverid process=$1 serverid=$(pidof -x wyiwServer awk '{print $1}') # 输出服务的pid echo ${serverid} # -n如果变狼 serverid 字符串长度大于0 则为真 执行停止服务 if [ -n "$serverid" ]; then echo ${serverid} echo "*************wyiwServer stop start****************" echo "***" echo "*****" echo "******" echo "**************" echo "***********************" echo "*******************************" echo "**************************************" echo "*****************************************" # 停止服务 kill -9 ${serverid} echo "*************wyiwServer stop successful***********" fi echo "*************wyiwServer start init********************" # 后台启动服务 nohup ./wyiwServer >/dev/null 2>error.log 2>&1 & ps -aux |grep wyiwServer echo "*************wyiwServer start successful***************"
-
脚本验证结果
[root@iZuf6hdnp1nizm6oia7sx7Z service]# ./start.sh *************wyiwServer start check******************* root 27285 0.0 0.5 714372 18524 pts/1 Sl 13:05 0:00 ./wyiwServer root 27815 0.0 0.0 112828 2312 pts/1 R+ 13:16 0:00 grep wyiwServer 27285 27285 *************wyiwServer stop start**************** *** ***** ****** ************** *********************** ******************************* ************************************** ***************************************** *************wyiwServer stop successful*********** *************wyiwServer start init******************** root 27817 0.0 0.2 714372 10232 pts/1 Rl+ 13:16 0:00 ./wyiwServer root 27819 0.0 0.0 112824 2320 pts/1 S+ 13:16 0:00 grep wyiwServer *************wyiwServer start successful***************
-
结构如下:
标签:shell,启动,0.0,echo,start,wyiwServer,go,serverid,root 来源: https://blog.csdn.net/LB3701/article/details/116124866