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:
Michael Kaufmann (d00p)
2011-02-09 09:53:05 +01:00
parent 6dca567827
commit cb36615228

View File

@@ -194,25 +194,21 @@ while($row = $db->fetch_array($result))
// make the stuff readable for the customer, #258 // make the stuff readable for the customer, #258
makeChownWithNewStats($row); makeChownWithNewStats($row);
}
/** /**
* Webalizer might run for some time, so we'd better check if our database is still present * Webalizer/AWStats might run for some time, so we'd better check if our database is still present
*/ */
if (empty($db->link_id)
if(empty($db->link_id)
|| $db->link_id === false) || $db->link_id === false)
{ {
fwrite($debugHandler, 'Database-connection seems to be down, trying to reconnect' . "\n"); fwrite($debugHandler, 'Database-connection seems to be down, trying to reconnect' . "\n");
// just in case // just in case
$db->close(); $db->close();
require_once ($pathtophpfiles . '/lib/userdata.inc.php'); require_once ($pathtophpfiles . '/lib/userdata.inc.php');
$db = new db($sql['host'], $sql['user'], $sql['password'], $sql['db']); $db = new db($sql['host'], $sql['user'], $sql['password'], $sql['db']);
if($db->link_id == 0) if ($db->link_id == 0) {
{
fclose($debugHandler); fclose($debugHandler);
unlink($lockfile); unlink($lockfile);
$cronlog->logAction(CRON_ACTION, LOG_ERR, 'Database-connection crashed during traffic-cronjob, could not reconnect!'); $cronlog->logAction(CRON_ACTION, LOG_ERR, 'Database-connection crashed during traffic-cronjob, could not reconnect!');
@@ -225,6 +221,8 @@ while($row = $db->fetch_array($result))
$cronlog->logAction(CRON_ACTION, LOG_WARNING, 'Database-connection crashed during traffic-cronjob, reconnected!'); $cronlog->logAction(CRON_ACTION, LOG_WARNING, 'Database-connection crashed during traffic-cronjob, reconnected!');
} }
}
/** /**
* FTP-Traffic * FTP-Traffic
*/ */