Merge pull request #1545 from annando/1503-load-issues

Value for maximum load until the frontend quits service
This commit is contained in:
Tobias Diekershoff 2015-05-03 09:15:54 +02:00
commit a37f31b82f
6 changed files with 21 additions and 3 deletions

View File

@ -30,7 +30,7 @@ function cronhooks_run(&$argv, &$argc){
if(function_exists('sys_getloadavg')) {
$load = sys_getloadavg();
if(intval($load[0]) > $maxsysload) {
logger('system: load ' . $load . ' too high. Poller deferred to next scheduled run.');
logger('system: load ' . $load[0] . ' too high. Cronhooks deferred to next scheduled run.');
return;
}
}

View File

@ -60,7 +60,7 @@ function delivery_run(&$argv, &$argc){
if(function_exists('sys_getloadavg')) {
$load = sys_getloadavg();
if(intval($load[0]) > $maxsysload) {
logger('system: load ' . $load . ' too high. Delivery deferred to next queue run.');
logger('system: load ' . $load[0] . ' too high. Delivery deferred to next queue run.');
return;
}
}

View File

@ -46,7 +46,7 @@ function poller_run(&$argv, &$argc){
if(function_exists('sys_getloadavg')) {
$load = sys_getloadavg();
if(intval($load[0]) > $maxsysload) {
logger('system: load ' . $load . ' too high. Poller deferred to next scheduled run.');
logger('system: load ' . $load[0] . ' too high. Poller deferred to next scheduled run.');
return;
}
}

View File

@ -53,6 +53,20 @@ if(!$install) {
load_config('config');
load_config('system');
$maxsysload_frontend = intval(get_config('system','maxloadavg_frontend'));
if($maxsysload_frontend < 1)
$maxsysload_frontend = 50;
if(function_exists('sys_getloadavg')) {
$load = sys_getloadavg();
if(intval($load[0]) > $maxsysload_frontend) {
logger('system: load ' . $load[0] . ' too high. Service Temporarily Unavailable.');
header($_SERVER["SERVER_PROTOCOL"].' 503 Service Temporarily Unavailable');
header('Retry-After: 300');
die("System is currently unavailable. Please try again later");
}
}
if (get_config('system','force_ssl') AND ($a->get_scheme() == "http") AND
(intval(get_config('system','ssl_policy')) == SSL_POLICY_FULL) AND
(substr($a->get_baseurl(), 0, 8) == "https://")) {

View File

@ -357,6 +357,7 @@ function admin_page_site_post(&$a){
$delivery_interval = ((x($_POST,'delivery_interval')) ? intval(trim($_POST['delivery_interval'])) : 0);
$poll_interval = ((x($_POST,'poll_interval')) ? intval(trim($_POST['poll_interval'])) : 0);
$maxloadavg = ((x($_POST,'maxloadavg')) ? intval(trim($_POST['maxloadavg'])) : 50);
$maxloadavg_frontend = ((x($_POST,'maxloadavg_frontend')) ? intval(trim($_POST['maxloadavg_frontend'])) : 50);
$dfrn_only = ((x($_POST,'dfrn_only')) ? True : False);
$ostatus_disabled = !((x($_POST,'ostatus_disabled')) ? True : False);
$ostatus_poll_interval = ((x($_POST,'ostatus_poll_interval')) ? intval(trim($_POST['ostatus_poll_interval'])) : 0);
@ -423,6 +424,7 @@ function admin_page_site_post(&$a){
set_config('system','delivery_interval',$delivery_interval);
set_config('system','poll_interval',$poll_interval);
set_config('system','maxloadavg',$maxloadavg);
set_config('system','maxloadavg_frontend',$maxloadavg_frontend);
set_config('config','sitename',$sitename);
set_config('config','hostname',$hostname);
set_config('config','sender_email', $sender_email);
@ -677,6 +679,7 @@ function admin_page_site(&$a) {
'$delivery_interval' => array('delivery_interval', t("Delivery interval"), (x(get_config('system','delivery_interval'))?get_config('system','delivery_interval'):2), t("Delay background delivery processes by this many seconds to reduce system load. Recommend: 4-5 for shared hosts, 2-3 for virtual private servers. 0-1 for large dedicated servers.")),
'$poll_interval' => array('poll_interval', t("Poll interval"), (x(get_config('system','poll_interval'))?get_config('system','poll_interval'):2), t("Delay background polling processes by this many seconds to reduce system load. If 0, use delivery interval.")),
'$maxloadavg' => array('maxloadavg', t("Maximum Load Average"), ((intval(get_config('system','maxloadavg')) > 0)?get_config('system','maxloadavg'):50), t("Maximum system load before delivery and poll processes are deferred - default 50.")),
'$maxloadavg_frontend' => array('maxloadavg_frontend', t("Maximum Load Average (Frontend)"), ((intval(get_config('system','maxloadavg_frontend')) > 0)?get_config('system','maxloadavg_frontend'):50), t("Maximum system load before the frontend quits service - default 50.")),
'$use_fulltext_engine' => array('use_fulltext_engine', t("Use MySQL full text engine"), get_config('system','use_fulltext_engine'), t("Activates the full text engine. Speeds up search - but can only search for four and more characters.")),
'$suppress_language' => array('suppress_language', t("Suppress Language"), get_config('system','suppress_language'), t("Suppress language information in meta information about a posting.")),

View File

@ -107,6 +107,7 @@
{{include file="field_input.tpl" field=$delivery_interval}}
{{include file="field_input.tpl" field=$poll_interval}}
{{include file="field_input.tpl" field=$maxloadavg}}
{{include file="field_input.tpl" field=$maxloadavg_frontend}}
{{include file="field_input.tpl" field=$abandon_days}}
{{include file="field_input.tpl" field=$lockpath}}
{{include file="field_input.tpl" field=$temppath}}