diff --git a/interface/web/admin/templates/server_config_rescue_edit.htm b/interface/web/admin/templates/server_config_rescue_edit.htm
index 1642a1256ae3d1d6da58f5ce02cae45a2a384811..ccb94081f6e1780c8603732ae06b385d974b6619 100644
--- a/interface/web/admin/templates/server_config_rescue_edit.htm
+++ b/interface/web/admin/templates/server_config_rescue_edit.htm
@@ -30,6 +30,9 @@
+
+ Information: If you want to shut down mysql you have to disable "rescue mysql" and then wait 2-3 minutes.
+ if you do not wait 2-3 minutes, rescue will try to restart mysql!
diff --git a/server/lib/classes/monitor_tools.inc.php b/server/lib/classes/monitor_tools.inc.php
index 3ac85932e55ea50982ba16e268cc7f6e1c002ea7..6539a1ae4a4861e965ea0eb74d00510e107acfd7 100644
--- a/server/lib/classes/monitor_tools.inc.php
+++ b/server/lib/classes/monitor_tools.inc.php
@@ -519,7 +519,7 @@ class monitor_tools {
$server_id = intval($conf['server_id']);
/** get the "active" Services of the server from the DB */
- $services = $app->dbmaster->queryOneRecord('SELECT * FROM server WHERE server_id = ' . $server_id);
+ $services = $app->db->queryOneRecord('SELECT * FROM server WHERE server_id = ' . $server_id);
/*
* If the DB is down, we have to set the db to "yes".
* If we don't do this, then the monitor will NOT monitor, that the db is down and so the
diff --git a/server/mods-available/rescue_core_module.inc.php b/server/mods-available/rescue_core_module.inc.php
index 6a8634442af13041b81d1955209d7bd526fc4738..f1c34cadbd4ec8ce63cc90a9e899fd06f8e2f7e7 100644
--- a/server/mods-available/rescue_core_module.inc.php
+++ b/server/mods-available/rescue_core_module.inc.php
@@ -89,14 +89,14 @@ class rescue_core_module {
$this->_rescueData = $this->_getRescueData();
/*
- * rescue apache if needed
+ * rescue mysql if needed (maybe apache depends on mysql, so try this first!)
*/
- $this->_rescueApache();
+ $this->_rescueMySql();
/*
- * rescue mysql if needed
+ * rescue apache if needed
*/
- $this->_rescueMySql();
+ $this->_rescueApache();
/*
* The last step is to save the rescue-data
@@ -273,7 +273,6 @@ class rescue_core_module {
$app->log('Apache is down! Try rescue apache (try:' . $tryCount . ')...', LOGLEVEL_WARN);
-// echo 'Apache is down! Try rescue apache (try:' . $tryCount . ')...';
if(is_file($conf['init_scripts'] . '/' . 'httpd')) {
$daemon = 'httpd';
@@ -340,7 +339,6 @@ class rescue_core_module {
$app->log('MySQL is down! Try rescue mysql (try:' . $tryCount . ')...', LOGLEVEL_WARN);
-// echo 'MySQL is down! Try rescue mysql (try:' . $tryCount . ')...';
if(is_file($conf['init_scripts'] . '/' . 'mysqld')) {
$daemon = 'mysqld';
diff --git a/server/server.php b/server/server.php
index 6a3499fd5bc3d836f07fc1ba33fdfbf08d3d3b8d..c171d4848907b941d75d90fa7dad106f52953480 100644
--- a/server/server.php
+++ b/server/server.php
@@ -1,7 +1,7 @@
dbmaster->connect()) {
- // get the dalaog_id of the last performed record
$server_db_record = $app->dbmaster->queryOneRecord("SELECT * FROM server WHERE server_id = " . $conf['server_id']);
+
$conf['last_datalog_id'] = (int) $server_db_record['updated'];
$conf['mirror_server_id'] = (int) $server_db_record['mirror_server_id'];
+
// Load the ini_parser
$app->uses('ini_parser');
+
// Get server configuration
$conf['serverconfig'] = $app->ini_parser->parse_ini_string(stripslashes($server_db_record['config']));
+
// Set the loglevel
$conf['log_priority'] = intval($conf['serverconfig']['server']['loglevel']);
+ // we do not need this variable anymore
unset($server_db_record);
+
+ /*
+ * Save the rescue-config, maybe we need it (because the database is down)
+ */
+ $tmp['serverconfig']['server']['loglevel'] = $conf['log_priority'];
+ $tmp['serverconfig']['rescue'] = $conf['serverconfig']['rescue'];
+ file_put_contents(dirname(__FILE__) . "/temp/rescue_module_serverconfig.ser.txt", serialize($tmp));
+ unset($tmp);
+
+ // protect the file
+ chmod(dirname(__FILE__) . "/temp/rescue_module_serverconfig.ser.txt", 0600);
+
} else {
/*
* The master-db is not available.
* Problem: because we need to start the rescue-module (to rescue the DB if this IS the
* server, the master-db is running at) we have to initialize some config...
*/
- $conf['last_datalog_id'] = intval('9223372036854775807'); // maxint at 32 and 64 bit systems
- $conf['mirror_server_id'] = 0; // no mirror
- // Set the loglevel to warning
- $conf['log_priority'] = LOGLEVEL_WARN;
+
+ /*
+ * If there is a temp-file with the data we could get from the database, then we use it
+ */
+ $tmp = array();
+ if (file_exists(dirname(__FILE__) . "/temp/rescue_module_serverconfig.ser.txt")){
+ $tmp = unserialize(file_get_contents(dirname(__FILE__) . "/temp/rescue_module_serverconfig.ser.txt"));
+ }
+
+ // maxint at 32 and 64 bit systems
+ $conf['last_datalog_id'] = intval('9223372036854775807');
+
+ // no mirror
+ $conf['mirror_server_id'] = 0;
+
+ // Set the loglevel
+ $conf['log_priority'] = (isset($tmp['serverconfig']['server']['loglevel']))? $tmp['serverconfig']['server']['loglevel'] : LOGLEVEL_ERROR;
/*
* Set the configuration to rescue the database
*/
- $conf['serverconfig']['rescue']['try_rescue'] = 'y';
- $conf['serverconfig']['rescue']['do_not_try_rescue_mysql'] = 'n';
+ if (isset($tmp['serverconfig']['rescue'])){
+ $conf['serverconfig']['rescue'] = $tmp['serverconfig']['rescue'];
+ }
+ else{
+ $conf['serverconfig']['rescue']['try_rescue'] = 'n';
+ }
+ // we do not need this variable anymore
+ unset($tmp);
}