automatic server restart

Everything technical and nerdy stuff here plz !

automatic server restart

Postby wurst » 12.27.08

oki guys, heres next try for restarting the gameserver in the case it dont answer properly.
it is (thx xtj7) a little php script that use rcon protocol for querying the gameserver status (like hlsw etc)
if the answer dont contain "statusResponse", the restart batch will kill the server via taskkill and start it again.

thats the checking script
Code: Select all
<?php
$fp = fsockopen( 'udp://127.0.0.1', 22222, $errno, $error, 1 );
fwrite( $fp, "xFFxFFxFFxFFgetstatusx00" );

if( $fp && strpos( fgets( $fp, 2048 ), "statusResponse" ) ) {
   echo( 'Server alive' );
} else {
   echo( 'Server died' );
   system( "C:/gameservers/UrbanTerror/ForceRestart.bat && exit", $output );
   echo( 'Attempting restart...' );
}
?>


...and thats the C:/gameservers/UrbanTerror/ForceRestart.bat
Code: Select all
taskkill /F /IM ioUrTded.exe
taskkill /F /IM python.exe
C:gameserversUrbanTerror22222.bat
sendemail -f gameserver@dswp.de -s xxx.xxx.xxx.xxx:225 -t lol@huhu -t spam@me.com -u huhu -m omg i did it again.


ah 2 notes:
-allways be sure to remember the save mode before use exec(), passthru() or system()
-sendemail.exe command line mail client can be found free at http://www.caspian.dotconf.net/menu/Software/SendEmail/
-be patient for the case our little "sylvesterknaller" has a littel "new-years-eve-backfire-issues"

gg :D
Image
User avatar
wurst
Godlike
 
Posts: 4648
Joined: 07.15.08
Location: Behind U
-----tdm:  
nick: [dswp]GewitterOma
skill: 1122.83
kills: 25960
deaths: 19847
ratio: 1.30
-----bomb:  
nick: [dswp]GewitterOma
skill: 812.172
kills: 3885
deaths: 3541
ratio: 1.09

Re: automatic server restart

Postby wurst » 12.31.08

oki heres new version of the thing. xtj7 built some test repeating in since some times rcon dont answer.

the script test several times before its going to restart serwer :)


Code: Select all
<?php
$check_attempts = 5;
$check_ip = '192.168.9.1';
$check_port = 22222;
$check_timeout = 1;
$check_wait = 1;
$check_call = "START C:/gameservers/UrbanTerror/ForceRestart.bat && exit";

// Code
$failed = true;
$attempts = $check_attempts;
while( $attempts > 0 ) {
   if( checkUrTServer( $check_ip, $check_port, $check_timeout ) ) {
      $attempts = 0;
      $failed = false;
   } else {
      sleep( $check_wait );
      $attempts --;
   }
}

// Actions to perform on success / fail
if( $failed == true ) {
   echo( 'Server died...' );
   system( $check_call, $output );
} else {
   echo( 'Server alive' );
}

// Functions
function checkUrTServer( $ip, $port = 22222, $timeout = 1 ) {
   $fp = fsockopen( 'udp://' . $ip, $port, $errno, $error, $timeout ); 
   fwrite( $fp, "xFFxFFxFFxFFgetstatusx00" );
   if( $fp && strpos( fgets( $fp, 2048 ), "statusResponse" ) ) {
      return( true );
   } else {
      return( false );
   }
}
?>
Image
User avatar
wurst
Godlike
 
Posts: 4648
Joined: 07.15.08
Location: Behind U
-----tdm:  
nick: [dswp]GewitterOma
skill: 1122.83
kills: 25960
deaths: 19847
ratio: 1.30
-----bomb:  
nick: [dswp]GewitterOma
skill: 812.172
kills: 3885
deaths: 3541
ratio: 1.09

Re: automatic server restart

Postby XTJ7 » 01.01.09

Aww, if I had known you wanted to publish it, I had made the code look pretty and not some ugly scribbling like that... :D Well, too late. It's only a simple and dirty solution for a problem that isn't supposed to exist in the first place.
So guys, if the server doesn't respond, visit the forum and it's supposed to restart.
<XTJ7> !penis
<CuntBot> XTJ7, your penis is 23.3 cm long. 8=========D
<XTJ7> !8ball do i rock?
<CuntBot> XTJ7: OH YEAH !
<BEH> !8ball you lieing too?
<CuntBot> BEH: Totally not.
<BEH> -_-''
User avatar
XTJ7
Kanzlerin
 
Posts: 1063
Joined: 07.24.08
Location: Germany
-----tdm:  
nick: [dswp]xtj7
skill: 753.35
kills: 98
deaths: 95
ratio: 1.03

Re: automatic server restart

Postby wurst » 01.03.09

its a problem that dont exist anylonger thx supi code :)
Image
User avatar
wurst
Godlike
 
Posts: 4648
Joined: 07.15.08
Location: Behind U
-----tdm:  
nick: [dswp]GewitterOma
skill: 1122.83
kills: 25960
deaths: 19847
ratio: 1.30
-----bomb:  
nick: [dswp]GewitterOma
skill: 812.172
kills: 3885
deaths: 3541
ratio: 1.09

Re: automatic server restart

Postby wurst » 01.10.09

ah btw, for our "windows users"

:D :lol: :? :) ;) :( :shock:

if u have the same prob like me:
(the batch stops when starting the gameserver, it will just continue when the urt console window closes)

use hstart with /NOCONSOLE to start the iourtded.exe
very nice progi, it keeps the promise that bill gave with the "start" command

heres site:
http://www.ntwind.com/software/utilities/hstart.html

heres its capabilities:

hstart_help21.png
(31.69 KiB) Downloaded 4114 times


it means that the gameserver will be restarted again and again and again, no matter how long im in holiday.
Image
User avatar
wurst
Godlike
 
Posts: 4648
Joined: 07.15.08
Location: Behind U
-----tdm:  
nick: [dswp]GewitterOma
skill: 1122.83
kills: 25960
deaths: 19847
ratio: 1.30
-----bomb:  
nick: [dswp]GewitterOma
skill: 812.172
kills: 3885
deaths: 3541
ratio: 1.09


Who is online

Users browsing this forum: No registered users and 0 guests

Misc