From bdf503d7fcab4c65e305462a1f91ea63d9577f79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffen=20Schro=CC=88der?= Date: Mon, 25 Aug 2014 15:10:46 +0200 Subject: [PATCH] catch transport exception on restart-shutdown --- application/core/ManiaControl.php | 201 +++++++++++++++--------------- 1 file changed, 100 insertions(+), 101 deletions(-) diff --git a/application/core/ManiaControl.php b/application/core/ManiaControl.php index 99e11a76..3a965161 100644 --- a/application/core/ManiaControl.php +++ b/application/core/ManiaControl.php @@ -167,18 +167,6 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener { $this->getTimerManager()->registerTimerListening($this, 'checkConnection', 1000 * 30); } - /** - * Print a message to console and log - * - * @param string $message - * @param bool $stripCodes - * @deprecated - * @see Logger::log() - */ - public function log($message, $stripCodes = false) { - Logger::log($message, $stripCodes); - } - /** * Load the Config XML-File */ @@ -208,12 +196,21 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener { } /** - * Return the actions menu + * Return the client * - * @return ActionsMenu + * @return Connection */ - public function getActionsMenu() { - return $this->actionsMenu; + public function getClient() { + return $this->client; + } + + /** + * Return the error handler + * + * @return ErrorHandler + */ + public function getErrorHandler() { + return $this->errorHandler; } /** @@ -226,21 +223,42 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener { } /** - * Return the callback manager + * Return the command manager * - * @return CallbackManager + * @return CommandManager */ - public function getCallbackManager() { - return $this->callbackManager; + public function getCommandManager() { + return $this->commandManager; } /** - * Return the chat + * Return the timer manager * - * @return Chat + * @return TimerManager */ - public function getChat() { - return $this->chat; + public function getTimerManager() { + return $this->timerManager; + } + + /** + * Print a message to console and log + * + * @param string $message + * @param bool $stripCodes + * @deprecated + * @see Logger::log() + */ + public function log($message, $stripCodes = false) { + Logger::log($message, $stripCodes); + } + + /** + * Return the actions menu + * + * @return ActionsMenu + */ + public function getActionsMenu() { + return $this->actionsMenu; } /** @@ -261,24 +279,6 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener { return $this->configurator; } - /** - * Return the client - * - * @return Connection - */ - public function getClient() { - return $this->client; - } - - /** - * Return the command manager - * - * @return CommandManager - */ - public function getCommandManager() { - return $this->commandManager; - } - /** * Return the database * @@ -315,24 +315,6 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener { return $this->playerManager; } - /** - * Return the plugin manager - * - * @return PluginManager - */ - public function getPluginManager() { - return $this->pluginManager; - } - - /** - * Return the server - * - * @return Server - */ - public function getServer() { - return $this->server; - } - /** * Return the setting manager * @@ -351,42 +333,6 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener { return $this->statisticManager; } - /** - * Return the update manager - * - * @return UpdateManager - */ - public function getUpdateManager() { - return $this->updateManager; - } - - /** - * Return the error handler - * - * @return ErrorHandler - */ - public function getErrorHandler() { - return $this->errorHandler; - } - - /** - * Return the timer manager - * - * @return TimerManager - */ - public function getTimerManager() { - return $this->timerManager; - } - - /** - * Return the file reader - * - * @return AsynchronousFileReader - */ - public function getFileReader() { - return $this->fileReader; - } - /** * Return the bill manager * @@ -417,6 +363,15 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener { $this->getChat()->sendInformation($message, $player); } + /** + * Return the chat + * + * @return Chat + */ + public function getChat() { + return $this->chat; + } + /** * Handle Restart AdminCommand * @@ -445,13 +400,12 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener { if ($message) { Logger::log($message); } - $this->getChat()->sendInformation('Restarting ManiaControl...'); - Logger::log('Restarting ManiaControl!'); - - // Hide widgets - if ($this->getClient()) { + try { + $this->getChat()->sendInformation('Restarting ManiaControl...'); $this->getClient()->sendHideManialinkPage(); + } catch (TransportException $exception) { } + Logger::log('Restarting ManiaControl!'); // Start new instance SystemUtil::restart(); @@ -460,6 +414,15 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener { $this->quit('Quitting ManiaControl to restart.'); } + /** + * Return the callback manager + * + * @return CallbackManager + */ + public function getCallbackManager() { + return $this->callbackManager; + } + /** * Handle Shutdown Command * @@ -568,6 +531,33 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener { $this->getServer()->getScriptManager()->enableScriptCallbacks(); } + /** + * Return the server + * + * @return Server + */ + public function getServer() { + return $this->server; + } + + /** + * Return the plugin manager + * + * @return PluginManager + */ + public function getPluginManager() { + return $this->pluginManager; + } + + /** + * Return the update manager + * + * @return UpdateManager + */ + public function getUpdateManager() { + return $this->updateManager; + } + /** * Perform the Main Loop */ @@ -596,6 +586,15 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener { } } + /** + * Return the file reader + * + * @return AsynchronousFileReader + */ + public function getFileReader() { + return $this->fileReader; + } + /** * Handle Server Stop Callback */