Scripted server with auto-restart?

Post here if you need help setting up your server, etc.
Post Reply
Moofie
Core Dumper
Posts: 125
Joined: Fri Jan 27, 2012 1:36 am
Location: Ohio
Contact:

Scripted server with auto-restart?

Post by Moofie »

So... I can start a server scripted, using

Code: Select all

#!/bin/sh
tron="/path/to/bin/armagetronad-dedicated"
var="/path/to/var/"
log="${var}console_log.txt"
userconfigdir="/path/to/config/"
parser="/path/to/parser.php"
ladderlog="${var}ladderlog.txt"
 
tail -n0 -f -s 0.01 $ladderlog | $parser | $tron --userconfigdir $userconfigdir --vardir $var | tee -a $log
and I can also start another server that will auto restart if it crashes with

Code: Select all

#!/bin/bash

loc="/home/armagetronad"
mkdir $loc/logs/$1
screen -S $1 -X logtstamp on 					# print timestamps in log file
screen -S $1 -X logfile $loc/logs/$1/$1_%m-%d-%Y-%c.log 	# create a logfile in the logs subf
screen -S $1 -X log on 					# Turn on logging for the server window
while true; do 						# start a loop to allow server restart if it crashes                         
           
# runs the actual server. By default, the binary is called armagetronad-dedicated and is located in the prefix/bin directory. In this example, it is
# in /home/armagetronad/bin directory.
	$loc/bin/armagetronad-dedicated --vardir $loc/servers/$1/var                              
# Shows the errors and indicates that the server has crashed, and then, waits 5 seconds before restarting the server, allowing you to quit with CTRL-C
       echo "Server has crashed. It will restart immediately..., press CTRL-C to cancel"
       sleep 5                                                                                                                                          
done # end the loop
but I can't figure out how to do both. The main problem I see right now is the scripted server script is shell, and the auto restart is in bash. Would I be able to convert one of them to the other then use it together? Any ideas on how to have the scripted start when crashing would help.
User avatar
Lucifer
Project Developer
Posts: 8683
Joined: Sun Aug 15, 2004 3:32 pm
Location: Republic of Texas
Contact:

Re: Scripted server with auto-restart?

Post by Lucifer »

Maybe you should try using the script provided in the distribution.
Image

Be the devil's own, Lucifer's my name.
- Iron Maiden
User avatar
Z-Man
God & Project Admin
Posts: 11624
Joined: Sun Jan 23, 2005 6:01 pm
Location: Cologne
Contact:

Re: Scripted server with auto-restart?

Post by Z-Man »

Lucifer wrote:Maybe you should try using the script provided in the distribution.
And the SPAWN_SCRIPT mechanism.
User avatar
erocat
On Lightcycle Grid
Posts: 36
Joined: Tue Mar 27, 2012 3:23 am

Re: Scripted server with auto-restart?

Post by erocat »

Try taking a look at the scripts here to troubleshoot.

Code: Select all

screen -dmS $1 /home/armagetronad/scripts/restartscriptdir $1
Moofie
Core Dumper
Posts: 125
Joined: Fri Jan 27, 2012 1:36 am
Location: Ohio
Contact:

Re: Scripted server with auto-restart?

Post by Moofie »

Oh.. wow... I totally forgot about SPAWN_SCRIPT... fail.
Post Reply