Page 1 of 1

[ASECO2.x] Plugin | AutoRes v.62

Posted: 19 Sep 2009 17:01
by nocturne
AutoRes v.62...........Level: Intermediate
This plugin automatically restarts Aseco upon the event of a crash, and allows you to restart it ingame via the '/admin restartaseco' command (authorized by 'adminsuper' authitem).

Installation: Edit the 'res_script_path' and 'res_script_file' values at the top of the code below, then save into a php file in your plugins directory, then add the plugin to the 'plugins.xml' file

Code: Select all

<?php
class Auto_Restart extends Plugin {

// Set the path to the script to run Aseco here...  
//	Linux ex: '/home/user_dir/aseco_dir/'
//	Win ex: 'C:\dir\aseco_dir'
var $res_script_path = '';

// Set the name of the start script here...
//	Linux ex: 'Aseco.sh'
//	Win ex: 'Aseco.bat'
var $res_script_file = '';

//Don't touch
var $running = true;

function on_crash () {
	$this->Aseco->console('[AUTO-RES] Aseco shutting down...  attempting to restart.');
	$this->auto_restart();
	}

function auto_restart () {
	if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
		$exec = 'start /d '.$this->res_script_path.' '.$this->res_script_file;
	} else {
		$exec = 'cd '.$this->res_script_path.';sh '.$this->res_script_file;
		}
	$this->running or exec($exec);
	}

function chat_crash () {
	$this->Aseco->console('[AUTO-RES] Restarting Aseco...');
	$this->running = false;
	$this->running or die();
	}

}

$_PLUGIN = new Auto_Restart();
$_PLUGIN->setAuthor('-nocturne=-');
$_PLUGIN->setVersion(.62);
$_PLUGIN->setDescription('Restarts aseco on crash...  whatd you expect?');

$_PLUGIN->addEvent('onServerCrash', 'on_crash');
$_PLUGIN->addChatCommand('admin restartaseco', 'chat_crash', 'Restart Aseco', 'ADMINSUPER');
?>

Re: [ASECO2.x] Plugin | AutoRes v.62

Posted: 19 Sep 2009 17:08
by nocturne
Oh, and... *Use at your own risk...* :twisted:

Re: [ASECO2.x] Plugin | AutoRes v.62

Posted: 19 Sep 2009 17:53
by oliverde8
Don't Aseco restart automatically laready on Windows?

And on Linux wouldn't it be easier to change the aseco.sh file?

Re: [ASECO2.x] Plugin | AutoRes v.62

Posted: 19 Sep 2009 18:33
by nocturne
oliverde8 wrote:Don't Aseco restart automatically laready on Windows?

And on Linux wouldn't it be easier to change the aseco.sh file?
On either linux or windows, the script won't automatically restart itself unless it's run within a loop in the start script.

I personally chose this method since it works well with the pid handling scripts I hacked up (for status monitoring), and... it's simple! No sloppy loops or extra processes. And, also gives you the ability to restart aseco ingame.

Re: [ASECO2.x] Plugin | AutoRes v.62

Posted: 08 May 2010 18:05
by PoDz
Hi,

I'm getting this:
Fatal error: Call to undefined method Auto_Restart::addEvent() in /home/......../plugin.Auto_Restart.php on line 44

I'm using xaseco 1.10.
line 44: $_PLUGIN->addEvent('onServerCrash', 'on_crash');

Thanks.

Re: [ASECO2.x] Plugin | AutoRes v.62

Posted: 09 May 2010 08:04
by TheM
PoDz wrote:Hi,

I'm getting this:
Fatal error: Call to undefined method Auto_Restart::addEvent() in /home/......../plugin.Auto_Restart.php on line 44

I'm using xaseco 1.10.
line 44: $_PLUGIN->addEvent('onServerCrash', 'on_crash');

Thanks.
Please first look at the topic title before posting such questions.
As you're already telling us is that you are running XASECO v1.10,
the forum you're posting in is for ASECO/RASP 2.x.
This is a different system then XASECO and you can't use it's plugins in XASECO.

I dunno if this plugin also exists for XASECO, otherwise you'll have to port it ;)
Or use ASECO/RASP ofcourse.

Re: [ASECO2.x] Plugin | AutoRes v.62

Posted: 09 May 2010 16:11
by nocturne
There was an xaseco equivalent (sort of), but it's a bit more complicated to use. Honestly, though... It's not much use anyways -- auto restart doesn't always work (such as with fatal php errors), and you have to be knowledgeable enough to set up your own start script (in which case you can run the script in a loop anyways, making it even more redundant). It was just the best option available that was compatible with my previous host, and I figured it wouldn't hurt posting it.