forked from lvshiling/Fgame
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrestart.sh
More file actions
34 lines (30 loc) · 756 Bytes
/
restart.sh
File metadata and controls
34 lines (30 loc) · 756 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/bash
WORKPATH=$(cd `dirname $0`; pwd)
echo "当前目录$WORKPATH"
# 获取服务器列表
serverList=()
suffix=""
# 查找游戏服
for gameDir in `ls $WORKPATH`
do
if [[ -d "$WORKPATH/$gameDir" && $gameDir =~ game_[0-9]+ ]]
then
index=$(echo $gameDir | cut -d "_" -f2)
echo "游戏目录$gameDir,索引$index"
serverList+=("$index")
fi
done
while true
do
for serverIndex in "${serverList[@]}"
do
program="game_$suffix$serverIndex"
result=`pidof $program`
if [ -z "$result" ]
then
echo "$(date),服务器$program已经关闭,准备重启"
sh run.sh game restart $serverIndex
fi
done
sleep 5
done