check database-connection after each customer in traffic-cron (sometimes analyzing big access-logs takes too long), fixes #544
Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
@@ -194,35 +194,33 @@ while($row = $db->fetch_array($result))
|
||||
|
||||
// make the stuff readable for the customer, #258
|
||||
makeChownWithNewStats($row);
|
||||
}
|
||||
|
||||
/**
|
||||
* Webalizer might run for some time, so we'd better check if our database is still present
|
||||
*/
|
||||
|
||||
if(empty($db->link_id)
|
||||
|| $db->link_id === false)
|
||||
{
|
||||
fwrite($debugHandler, 'Database-connection seems to be down, trying to reconnect' . "\n");
|
||||
|
||||
// just in case
|
||||
|
||||
$db->close();
|
||||
require_once ($pathtophpfiles . '/lib/userdata.inc.php');
|
||||
$db = new db($sql['host'], $sql['user'], $sql['password'], $sql['db']);
|
||||
|
||||
if($db->link_id == 0)
|
||||
/**
|
||||
* Webalizer/AWStats might run for some time, so we'd better check if our database is still present
|
||||
*/
|
||||
if (empty($db->link_id)
|
||||
|| $db->link_id === false)
|
||||
{
|
||||
fclose($debugHandler);
|
||||
unlink($lockfile);
|
||||
$cronlog->logAction(CRON_ACTION, LOG_ERR, 'Database-connection crashed during traffic-cronjob, could not reconnect!');
|
||||
die('Froxlor can\'t connect to mysqlserver. Exiting...');
|
||||
fwrite($debugHandler, 'Database-connection seems to be down, trying to reconnect' . "\n");
|
||||
|
||||
// just in case
|
||||
$db->close();
|
||||
require_once ($pathtophpfiles . '/lib/userdata.inc.php');
|
||||
$db = new db($sql['host'], $sql['user'], $sql['password'], $sql['db']);
|
||||
|
||||
if ($db->link_id == 0) {
|
||||
fclose($debugHandler);
|
||||
unlink($lockfile);
|
||||
$cronlog->logAction(CRON_ACTION, LOG_ERR, 'Database-connection crashed during traffic-cronjob, could not reconnect!');
|
||||
die('Froxlor can\'t connect to mysqlserver. Exiting...');
|
||||
}
|
||||
|
||||
fwrite($debugHandler, 'Database-connection re-established' . "\n");
|
||||
unset($sql);
|
||||
unset($db->password);
|
||||
$cronlog->logAction(CRON_ACTION, LOG_WARNING, 'Database-connection crashed during traffic-cronjob, reconnected!');
|
||||
}
|
||||
|
||||
fwrite($debugHandler, 'Database-connection re-established' . "\n");
|
||||
unset($sql);
|
||||
unset($db->password);
|
||||
$cronlog->logAction(CRON_ACTION, LOG_WARNING, 'Database-connection crashed during traffic-cronjob, reconnected!');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user