2
0
mirror of https://github.com/ACSPRI/queXS synced 2024-04-02 12:12:16 +00:00

Add process_clear_log function to make sure process_log table doesn't get too big

This commit is contained in:
azammitdcarf
2012-09-27 01:01:02 +00:00
parent e085adafcc
commit 6f493f46b4
3 changed files with 35 additions and 0 deletions

View File

@@ -205,6 +205,8 @@ while (!is_process_killed($process_id)) //check if process killed every $sleepin
if (is_process_killed($process_id)){break;}
sleep($sleepinterval);
}
process_clear_log($process_id);
}
disable_systemsort();

View File

@@ -246,4 +246,33 @@ function process_get_last_data($type = 1)
return false;
}
/**
* Don't let the log get too big for this process
*
* @param int $process_id The process id
*
* @author Adam Zammit <adam.zammit@acspri.org.au>
* @since 2012-09-27
*/
function process_clear_log($process_id)
{
global $db;
$sql =
"DELETE FROM process_log WHERE process_id = '$process_id' AND
process_log_id NOT IN (
SELECT process_log_id
FROM (
SELECT process_log_id
FROM process_log
WHERE process_id = '$process_id'
ORDER BY process_log_id DESC
LIMIT " . (PROCESS_LOG_LIMIT * 3) . "
) x
)";
$db->Execute($sql);
}
?>

View File

@@ -621,6 +621,10 @@ class voipWatch extends voip {
$time = time();
}
if ($process_id) {
process_clear_log($process_id);
}
} while ($this->keepWatching);
}