Merge pull request #131 from klightspeed/1.3-dev#process

1.3 dev stop/restart
This commit is contained in:
Fez Vrasta 2015-07-26 20:55:02 +02:00
commit 3d635fa4c0

View File

@ -243,14 +243,22 @@ function getAvailableVersion(){
return $bnumber return $bnumber
} }
#
# Get the PID of the server process
#
function getServerPID(){
ps -ef | grep "$arkserverroot/$arkserverexec" | grep -v grep | awk '{print $2}'
}
# #
# Check id the server process is alive # Check id the server process is alive
# #
function isTheServerRunning(){ function isTheServerRunning(){
SERVICE="ShooterGameServer" if [ -n "`getServerPID`" ]; then
ps aux | grep -v grep | grep $SERVICE > /dev/null return 0
result=$? else
return $result return 1
fi
} }
# #
@ -326,13 +334,27 @@ doStop() {
if isTheServerRunning; then if isTheServerRunning; then
tput sc tput sc
echo "Stopping server..." echo "Stopping server..."
echo "`timestamp`: stopping" >> "$logdir/$arkmanagerLog"
# kill the server with the PID # kill the server with the PID
PID=`ps -ef | grep "$arkserverroot/$arkserverexec" | grep -v grep | awk '{print $2}'` PID=`getServerPID`
kill -9 $PID kill -INT $PID
for (( i = 0; i < 10; i++ )); do
sleep 1
if ! isTheServerRunning; then
break
fi
done
if isTheServerRunning; then
tput rc
echo "Killing server..."
kill -KILL $PID
fi
tput rc; tput ed; tput rc; tput ed;
echo "The server has been stopped" echo "The server has been stopped"
echo "`timestamp`: stop" >> "$logdir/$arkmanagerLog" echo "`timestamp`: stopped" >> "$logdir/$arkmanagerLog"
else else
echo "The server is already stopped" echo "The server is already stopped"
fi fi
@ -563,7 +585,7 @@ case "$1" in
restart) restart)
doStop doStop
echo "`timestamp`: stop" >> "$logdir/$arkmanagerLog" echo "`timestamp`: stop" >> "$logdir/$arkmanagerLog"
sleep 10 sleep 1
doStart doStart
echo "`timestamp`: start" >> "$logdir/$arkmanagerLog" echo "`timestamp`: start" >> "$logdir/$arkmanagerLog"
echo "`timestamp`: restart" >> "$logdir/$arkmanagerLog" echo "`timestamp`: restart" >> "$logdir/$arkmanagerLog"