forked from jxy918/swoole-game
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgame
executable file
·51 lines (48 loc) · 1.02 KB
/
game
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
function startgame()
{
printf "staring GameServer...\r\n"
php run.php >> ../log/server.log 2>&1
printf $?
if [ $? == 0 ]; then
printf "GameServer start OK\r\n"
return 0
else
printf "GameServer start FAIL\r\n"
return 1
fi
}
function stopgame()
{
printf "stoping GameServer...\r\n"
$(ps -ef | grep "game" | grep -v "grep" | awk '{print $2 }' | xargs kill -9)
PROCESS_NUM2=$(ps -ef | grep "game" | grep -v "grep" | awk '{print $2 }' | wc -l)
if [ $PROCESS_NUM2 == 0 ]; then
printf "GameServer stop OK\r\n"
return 0
else
printf "GameServer stop FAIL\r\n"
return 1
fi
}
function reload()
{
cmd=$(pidof game_master_Game_App_GameServer)
printf $cmd
kill -USR1 "$cmd"
printf "Reloaded is OK \r\n"
}
if [ $1 == "start" ]
then
#stopgame
sleep 1
startgame
elif [ $1 == "stop" ]
then
stopgame
elif [ $1 == "reload" ]
then
reload
else
printf "Please make sure the positon variable is start or stop.\r\n"
fi