[IMPROVED] Check system load, dashboard updates
This will suspend any dashboard updates if the system load exceeds a configurable threshold. Graphs will not update until the system load is again below the threshold. See dist config for new option. Should help those pools suffering from too many live update users.
This commit is contained in:
parent
9bd1f8e963
commit
4bd371ffc6
@ -456,4 +456,19 @@ $config['cookie']['secure'] = false;
|
||||
**/
|
||||
$config['smarty']['cache'] = 0;
|
||||
$config['smarty']['cache_lifetime'] = 30;
|
||||
|
||||
/**
|
||||
* System load setting
|
||||
*
|
||||
* This will disable loading of some API calls in case the system
|
||||
* loads exceeds the defined max setting. Useful to temporaily suspend
|
||||
* live statistics on a server that is too busy to deal with requests.
|
||||
*
|
||||
* Options
|
||||
* max = float, maximum system load
|
||||
*
|
||||
* Defaults:
|
||||
* max = 10.0
|
||||
**/
|
||||
$config['system']['load']['max'] = 10.0;
|
||||
?>
|
||||
|
||||
@ -3,6 +3,14 @@
|
||||
// Make sure we are called from index.php
|
||||
if (!defined('SECURITY')) die('Hacking attempt');
|
||||
|
||||
// System load check
|
||||
if ($load = @sys_getloadavg()) {
|
||||
if (isset($config['system']['load']['max']) && $load[0] > $config['system']['load']['max']) {
|
||||
header('HTTP/1.1 503 Too busy, try again later');
|
||||
die('Server too busy. Please try again later.');
|
||||
}
|
||||
}
|
||||
|
||||
// Check user token and access level permissions
|
||||
$user_id = $api->checkAccess($user->checkApiKey($_REQUEST['api_key']), @$_REQUEST['id']);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user