HomeServer/backRestart.sh

26 lines
920 B
Bash
Raw Permalink Normal View History

2024-11-20 15:41:09 +08:00
#!/bin/bash
PROJECT_PATH=$(cd `dirname $0`;pwd)
appName="home" #App名
centerUrl="http://192.168.50.111:8000/ServerManage" #内网管理地址
if [ -z $1 ]
then
echo "输入正确的游戏服ID"
else
#pid=$(pgrep -fl "$appName Server/Config/config_$1$" | grep -v grep | awk '{print $1}' )
pid=$(ps aux | grep -w "$appName Server/Config/config_$1" | grep -v "grep" | awk '{print $2}')
if [ "" = "$pid" ]
then
echo "未找到程序" $appName 进程ID
else
echo "向中心服注销" $appName "集群ID" $1 进程ID $pid
curl -m 500 -X POST -H "Content-Type: application/json" -d '{"cmd":888,"serverId":'$1'}' $centerUrl #100秒超时正常无人的游戏服会秒回
echo "关闭程序" $appName "集群ID" $1 进程ID $pid
kill -s 12 $pid
echo "重启程序" $appName "集群ID" $1
#nohup ./$appName Server/Config/config_$1 > /dev/null 2>&1 &
./$appName Server/Config/config_$1 &
fi
fi