Proper way to shutdown FAST 3.2.2c

Discover FAST, a records keeping server control script with a public records system called Dedimania, which will show records from the server on tm-exchange.com

Moderators: Slig, TM-Patrol

Post Reply
User avatar
svens
speedy pilot
speedy pilot
Posts: 304
Joined: 05 Dec 2009 23:30
Owned TM-games: TMUF, TMS, TMO
Location: Bern, CH
Contact:

Proper way to shutdown FAST 3.2.2c

Post by svens » 06 Dec 2009 22:26

Hey,

I'm searching for the "right" way to shutdown FAST. I'm pretty sure a simple die() will do the trick, but shouldn't the server connection be closed before?

User avatar
Slig
Pit Crew
Pit Crew
Posts: 2124
Joined: 05 Sep 2005 17:51
Owned TM-games: ALL
Location: TraxicoLand (Fr)
Contact:

Re: Proper way to shutdown FAST 3.2.2c

Post by Slig » 06 Dec 2009 23:55

Well, it's true that a $_client->Terminate(); before can't be bad, btw i think that it is really not needed, so socket connection will be closed when the script end, so the dedicated will know it. I never thought a problem on the dedicated after direct kill of the php script process.

note: the standard script which start Fast loop in case of an exit level 10, so if you want Fast to be restarted do an exit(10), or any other exit() or die() value to not have it restarted.

User avatar
svens
speedy pilot
speedy pilot
Posts: 304
Joined: 05 Dec 2009 23:30
Owned TM-games: TMUF, TMS, TMO
Location: Bern, CH
Contact:

Re: Proper way to shutdown FAST 3.2.2c

Post by svens » 07 Dec 2009 11:00

Cool, thanks for your answer.. For plugin development I have to restart FAST a lot, and I realized that there's no official way to shut it down :roflol: .. I wrote a small plugin, just if some developper can use it:

Code: Select all

<?php


//	FAST plugin serverControl
//	Allows to shutdown or restart FAST
//
//	inspired by the answer of Slig on this my tm-forum thread http://www.tm-forum.com/viewtopic.php?f=126&t=23892
//	written by Sven Stucki - www.svenstucki.ch


registerPlugin( "scontrol", 94 );


$scontrol_ver = "";
$scontrol_rc = 0;


function scontrolInit( $e ) {
	
	global $scontrol_ver, $scontrol_rc;
	
	$scontrol_ver = "0.1001";	// Version
	$scontrol_rc = 10;	// Errorlevel which invokes a FAST restart
	
	registerCommand( 'shutdown', "/shutdown closes this FAST instance." );
	registerCommand( 'restart', "/restart restarts this FAST instance (only works if started with original script)." );
	addCall( null, "ChatSendServerMessage", "scontrol: rev. ".$scontrol_ver." loaded" );

}


function chat_shutdown( $author, $login, $cmd ) {
	
	if( !verifyAdmin($login) ) {
		addCall( null, "ChatSendServerMessage", "Command /shutdown is for admins only! (acces denied for {$login})" );
		return;
	}
	
	addCall( null, "ChatSendServerMessage", '$f00Admin closed FAST...' );
	exit( 0 );
	
}


function chat_restart( $author, $login, $cmd ) {
	
	global $scontrol_rc;
	
	if( !verifyAdmin($login) ) {
		addCall( null, "ChatSendServerMessage", "Command /restart is for admins only! (acces denied for {$login})" );
		return;
	}
	
	addCall( null, "ChatSendServerMessage", '$f00Admin initiated FAST restart...' );
	exit( $scontrol_rc );
	
}


?>
Of course the 'ChatSendServerMessage' calls aren't executed, but I've left them in the code anyway.

User avatar
Slig
Pit Crew
Pit Crew
Posts: 2124
Joined: 05 Sep 2005 17:51
Owned TM-games: ALL
Location: TraxicoLand (Fr)
Contact:

Re: Proper way to shutdown FAST 3.2.2c

Post by Slig » 07 Dec 2009 14:05

A pseudo command like that should work too if you want to restart Fast : /debug _debug;exit(10);

jamie_macdonald
TM-Patrol
TM-Patrol
Posts: 1612
Joined: 10 Jul 2008 19:48
Owned TM-games: TMUF, TMNF, TMS
Manialink(s): ET
Location: London, UK
Contact:

Re: Proper way to shutdown FAST 3.2.2c

Post by jamie_macdonald » 16 Dec 2009 18:49

thx for this svens, slig...

this has allready come in handy for me as a forum lurker and a script noob that runs alot of fast servers ^^

ty for saving time and sharing info :1

Post Reply