add restart.sh

This commit is contained in:
aozhiwei 2019-04-26 20:14:16 +08:00
parent 850297aa91
commit 16675566db

31
server/bin/restart.sh Executable file
View File

@ -0,0 +1,31 @@
#!/bin/bash
source /etc/profile
source /root/.bash_profile
function kill_old_servers() {
ps -ef|grep "valgrind ./gameserver -i$1"|grep -v grep
if [ $? -eq 0 ]; then
ps -ef|grep "valgrind ./gameserver -i$1"|grep -v grep|awk '{print $2}'|xargs kill -9
fi
ps -ef|grep "gameserver -i$1"|grep -v grep
if [ $? -eq 0 ]; then
ps -ef|grep "gameserver -i$1"|grep -v grep|awk '{print $2}'|xargs kill -9
fi
}
function start_new_servers() {
nouse_valgrind=$2
if [ "$nouse_valgrind" = "1" ]; then
nohup ./gameserver -i $1 > gameserver.out 2>&1 &
sleep 1
else
nohup valgrind ./gameserver -i $1 > gameserver.out 2>&1 &
sleep 1
fi
echo restart ok
}
kill_old_servers
start_new_servers $1 $2