setting for disabling automatic mc restart

This commit is contained in:
Steffen Schröder 2014-04-28 14:14:04 +02:00
parent d2813fe001
commit 75b1e2155a
3 changed files with 30 additions and 9 deletions

View File

@ -38,8 +38,6 @@ class MigrationHelper {
$sourceClass = $this->getClass($sourceClass);
$targetClass = $this->getClass($targetClass);
var_dump($sourceClass, $targetClass);
$mysqli = $this->maniaControl->database->mysqli;
$query = "INSERT INTO `" . SettingManager::TABLE_SETTINGS . "` (`class`, `setting`, `type`, `value`, `default`)

View File

@ -4,6 +4,7 @@ namespace ManiaControl;
use ManiaControl\Files\FileUtil;
use ManiaControl\Update\UpdateManager;
use ManiaControl\Callbacks\Callbacks;
/**
* Error and Exception Manager Class
@ -17,6 +18,7 @@ class ErrorHandler {
* Constants
*/
const MC_DEBUG_NOTICE = "ManiaControl.DebugNotice";
const SETTING_RESTART_ON_EXCEPTION = 'Automatically restart on Exceptions';
/*
* Private Properties
@ -33,6 +35,13 @@ class ErrorHandler {
set_exception_handler(array(&$this, 'exceptionHandler'));
}
/**
* Initialize other Error Handler Features
*/
public function init() {
$this->maniaControl->settingManager->initSetting($this, self::SETTING_RESTART_ON_EXCEPTION, true);
}
/**
* ManiaControl ExceptionHandler
* ManiaControl Shuts down after exception
@ -62,8 +71,7 @@ class ErrorHandler {
}
if ($this->maniaControl->settingManager && $this->maniaControl->updateManager) {
$error['UpdateChannel'] = $this->maniaControl->settingManager->getSetting($this->maniaControl->updateManager,
UpdateManager::SETTING_UPDATECHECK_CHANNEL);
$error['UpdateChannel'] = $this->maniaControl->settingManager->getSetting($this->maniaControl->updateManager, UpdateManager::SETTING_UPDATECHECK_CHANNEL);
$error['ManiaControlVersion'] = $this->maniaControl->updateManager->getCurrentBuildDate();
}
else {
@ -85,7 +93,9 @@ class ErrorHandler {
}
}
$this->maniaControl->restart();
if ($this->shouldRestart()) {
$this->maniaControl->restart();
}
exit();
}
@ -104,8 +114,7 @@ class ErrorHandler {
return false;
}
$userError = ($errorNumber == E_USER_ERROR || $errorNumber == E_USER_WARNING || $errorNumber == E_USER_NOTICE ||
$errorNumber == E_USER_DEPRECATED);
$userError = ($errorNumber == E_USER_ERROR || $errorNumber == E_USER_WARNING || $errorNumber == E_USER_NOTICE || $errorNumber == E_USER_DEPRECATED);
// Log error
$errorTag = $this->getErrorTag($errorNumber);
@ -129,8 +138,7 @@ class ErrorHandler {
}
if ($this->maniaControl->settingManager && $this->maniaControl->updateManager) {
$error['UpdateChannel'] = $this->maniaControl->settingManager->getSetting($this->maniaControl->updateManager,
UpdateManager::SETTING_UPDATECHECK_CHANNEL);
$error['UpdateChannel'] = $this->maniaControl->settingManager->getSetting($this->maniaControl->updateManager, UpdateManager::SETTING_UPDATECHECK_CHANNEL);
$error['ManiaControlVersion'] = $this->maniaControl->updateManager->getCurrentBuildDate();
}
else {
@ -208,6 +216,19 @@ class ErrorHandler {
return "[PHP {$errorLevel}]";
}
/**
* Test if ManiaControl should restart automatically
*
* @return bool
*/
private function shouldRestart() {
if (!$this->maniaControl || !$this->maniaControl->settingManager) {
return false;
}
$setting = $this->maniaControl->settingManager->getSetting($this, self::SETTING_RESTART_ON_EXCEPTION, true);
return $setting;
}
/**
* Parse the Debug Backtrace into a String for the Error Report
*

View File

@ -130,6 +130,8 @@ class ManiaControl implements CommandListener, TimerListener {
//Check connection every 30 seconds
$this->timerManager->registerTimerListening($this, 'checkConnection', 1000 * 30);
$this->errorHandler->init();
}
/**