Commit 132081c0 authored by Marius Cramer's avatar Marius Cramer

- added check for mysql error to avoid flood of error messages/mails

parent 6d6643de
...@@ -32,6 +32,8 @@ define('SCRIPT_PATH', dirname($_SERVER["SCRIPT_FILENAME"])); ...@@ -32,6 +32,8 @@ define('SCRIPT_PATH', dirname($_SERVER["SCRIPT_FILENAME"]));
require SCRIPT_PATH."/lib/config.inc.php"; require SCRIPT_PATH."/lib/config.inc.php";
require SCRIPT_PATH."/lib/app.inc.php"; require SCRIPT_PATH."/lib/app.inc.php";
$app->setCaller('cron_daily');
set_time_limit(0); set_time_limit(0);
ini_set('error_reporting', E_ALL & ~E_NOTICE); ini_set('error_reporting', E_ALL & ~E_NOTICE);
......
...@@ -35,6 +35,7 @@ class app { ...@@ -35,6 +35,7 @@ class app {
var $loaded_modules = array(); var $loaded_modules = array();
var $loaded_plugins = array(); var $loaded_plugins = array();
var $_calling_script = '';
function __construct() { function __construct() {
...@@ -60,6 +61,23 @@ class app { ...@@ -60,6 +61,23 @@ class app {
} }
function setCaller($caller) {
$this->_calling_script = $caller;
}
function getCaller() {
return $this->_calling_script;
}
function forceErrorExit($errmsg = 'undefined') {
global $conf;
if($this->_calling_script == 'server') {
@unlink($conf['temppath'] . $conf['fs_div'] . '.ispconfig_lock');
}
die('Exiting because of error: ' . $errmsg);
}
function uses($classes) { function uses($classes) {
global $conf; global $conf;
......
...@@ -130,6 +130,8 @@ class db extends mysqli ...@@ -130,6 +130,8 @@ class db extends mysqli
} }
public function query($queryString) { public function query($queryString) {
global $app;
if($this->isConnected == false) return false; if($this->isConnected == false) return false;
$try = 0; $try = 0;
do { do {
...@@ -138,6 +140,17 @@ class db extends mysqli ...@@ -138,6 +140,17 @@ class db extends mysqli
if(!$ok) { if(!$ok) {
if(!$this->real_connect($this->dbHost, $this->dbUser, $this->dbPass, $this->dbName)) { if(!$this->real_connect($this->dbHost, $this->dbUser, $this->dbPass, $this->dbName)) {
$this->updateError('DB::query -> reconnect'); $this->updateError('DB::query -> reconnect');
if($this->errorNumber == '111') {
// server is not available
if($try > 9) {
if(isset($app) && isset($app->forceErrorExit)) {
$app->forceErrorExit('Database connection failure!');
}
// if we reach this, the app object is missing or has no exit method, so we continue as normal
}
sleep(30); // additional seconds, please!
}
if($try > 9) { if($try > 9) {
return false; return false;
} else { } else {
......
...@@ -31,6 +31,8 @@ define('SCRIPT_PATH', dirname($_SERVER["SCRIPT_FILENAME"])); ...@@ -31,6 +31,8 @@ define('SCRIPT_PATH', dirname($_SERVER["SCRIPT_FILENAME"]));
require SCRIPT_PATH."/lib/config.inc.php"; require SCRIPT_PATH."/lib/config.inc.php";
require SCRIPT_PATH."/lib/app.inc.php"; require SCRIPT_PATH."/lib/app.inc.php";
$app->setCaller('server');
set_time_limit(0); set_time_limit(0);
ini_set('error_reporting', E_ALL & ~E_NOTICE); ini_set('error_reporting', E_ALL & ~E_NOTICE);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment