From e1ceb050e19c7574bca146a8da7047ee4ff456b5 Mon Sep 17 00:00:00 2001 From: Marius Burkard <m.burkard@pixcept.de> Date: Sun, 10 Jul 2016 05:02:35 -0400 Subject: [PATCH] Merge branch 'stable-3.1' --- server/mods-available/rescue_core_module.inc.php | 74 +++++++++++++++++++++++++++++++++++- 1 files changed, 71 insertions(+), 3 deletions(-) diff --git a/server/mods-available/rescue_core_module.inc.php b/server/mods-available/rescue_core_module.inc.php index ca69a91..5e8f3db 100644 --- a/server/mods-available/rescue_core_module.inc.php +++ b/server/mods-available/rescue_core_module.inc.php @@ -95,6 +95,11 @@ $this->_rescueData = $this->_getRescueData(); /* + * rescue MongoDB if needed + */ +// $this->_rescueMongoDB(); + + /* * rescue mysql if needed (maybe httpd depends on mysql, so try this first!) */ $this->_rescueMySql(); @@ -175,8 +180,6 @@ /* Thats it */ return $data; } - - /** * This gets the rescue-Data, needed for rescuing the system. @@ -309,6 +312,71 @@ } + /** + * restarts MongoDB, if needed + */ +// private function _rescueMongoDB(){ +// global $app, $conf; + + /* + * do nothing, if it is not allowed to rescue mysql + */ +// if ((isset($conf['serverconfig']['rescue']['do_not_try_rescue_mongodb']) && ($conf['serverconfig']['rescue']['do_not_try_rescue_mongodb']) == 'y')){ +// return; +// } + + /* + * if the service is up and running, or the service is not installed there is nothing to do... + */ +// if ($this->_monitoringData[0][0]['data']['mongodbserver'] != 0){ +// /* Clear the try counter, because we do not have to try to rescue the service */ +// $this->_rescueData['mongodbserver']['try_counter'] = 0; +// return; +// } + + /* + * OK, the service is installed and down. + * Maybe this is because of a restart of the service by the admin. + * This means, we check the data 1 minute ago + */ +// if ((!isset($this->_monitoringData[1][0]['data']['mongodbserver'])) || +// ((isset($this->_monitoringData[1][0]['data']['mongodbserver'])) && ($this->_monitoringData[1][0]['data']['mongodbserver'] != 0))){ + /* + * We do NOT have this data or we have this data, but the webserver was not down 1 minute ago. + * This means, it could be, that the admin is restarting the server. + * We wait one more minute... + */ +// return; +// } + + /*##### + * The service is down and it was down 1 minute ago. + * We try to rescue it + *#####*/ + + /* Get the try counter */ +// $tryCount = (!isset($this->_rescueData['mongodbserver']['try_counter']))? 1 : $this->_rescueData['mongodbserver']['try_counter'] + 1; + + /* Set the new try counter */ +// $this->_rescueData['mongodbserver']['try_counter'] = $tryCount; + + /* if 5 times will not work, we have to give up... */ +// if ($tryCount > 5){ +// $app->log('MongoDB is down! Rescue will not help!', LOGLEVEL_ERROR); +// return; +// } + + +// $app->log('MongoDB is down! Try rescue MongoDB (try:' . $tryCount . ')...', LOGLEVEL_WARN); + +// if(is_file($conf['init_scripts'] . '/' . 'mongodb')) { +// $daemon = 'mongodb'; +// } else { +// $daemon = 'mongodb'; +// } + +// $this->_rescueDaemon($daemon); +// } /** * restarts mysql, if needed @@ -382,7 +450,7 @@ * @param type $daemon the name of the daemon */ private function _rescueDaemon($daemon){ - global $conf; + global $app, $conf; $app->uses('system'); // if you need to find all restarts search for "['init_scripts']" -- Gitblit v1.9.1