From 62bacbb833c5a8847dff5fc9db232638440f6f38 Mon Sep 17 00:00:00 2001 From: Philipp Date: Mon, 1 Nov 2021 13:54:54 +0100 Subject: [PATCH] Remove 'maxloadavg_frontend' restriction in Friendica --- src/App.php | 8 -------- src/Core/System.php | 25 +++++------------------- src/Module/Admin/Site.php | 3 --- static/settings.config.php | 4 ---- view/templates/admin/site.tpl | 1 - view/theme/frio/templates/admin/site.tpl | 1 - 6 files changed, 5 insertions(+), 37 deletions(-) diff --git a/src/App.php b/src/App.php index f30c673ff5..75f5314af5 100644 --- a/src/App.php +++ b/src/App.php @@ -588,14 +588,6 @@ class App throw new HTTPException\InternalServerErrorException('Apologies but the website is unavailable at the moment.'); } - // Max Load Average reached: ERROR - if ($this->system->isMaxProcessesReached() || $this->system->isMaxLoadReached()) { - header('Retry-After: 120'); - header('Refresh: 120; url=' . $this->baseURL->get() . "/" . $this->args->getQueryString()); - - throw new HTTPException\ServiceUnavailableException('The node is currently overloaded. Please try again later.'); - } - if (!$this->mode->isInstall()) { // Force SSL redirection if ($this->baseURL->checkRedirectHttps()) { diff --git a/src/Core/System.php b/src/Core/System.php index 44249175a7..9002c5a7b3 100644 --- a/src/Core/System.php +++ b/src/Core/System.php @@ -42,11 +42,6 @@ class System */ private $logger; - /** - * @var App\Mode - */ - private $mode; - /** * @var IManageConfigValues */ @@ -57,10 +52,9 @@ class System */ private $basePath; - public function __construct(LoggerInterface $logger, App\Mode $mode, IManageConfigValues $config, string $basepath) + public function __construct(LoggerInterface $logger, IManageConfigValues $config, string $basepath) { $this->logger = $logger; - $this->mode = $mode; $this->config = $config; $this->basePath = $basepath; } @@ -156,24 +150,15 @@ class System */ public function isMaxLoadReached(): bool { - if ($this->mode->isBackend()) { - $process = 'backend'; - $maxsysload = intval($this->config->get('system', 'maxloadavg')); - if ($maxsysload < 1) { - $maxsysload = 50; - } - } else { - $process = 'frontend'; - $maxsysload = intval($this->config->get('system', 'maxloadavg_frontend')); - if ($maxsysload < 1) { - $maxsysload = 50; - } + $maxsysload = intval($this->config->get('system', 'maxloadavg')); + if ($maxsysload < 1) { + $maxsysload = 50; } $load = System::currentLoad(); if ($load) { if (intval($load) > $maxsysload) { - $this->logger->warning('system load for process too high.', ['load' => $load, 'process' => $process, 'maxsysload' => $maxsysload]); + $this->logger->warning('system load for process too high.', ['load' => $load, 'process' => 'backend', 'maxsysload' => $maxsysload]); return true; } } diff --git a/src/Module/Admin/Site.php b/src/Module/Admin/Site.php index 2cc4ac23a3..9d769cba79 100644 --- a/src/Module/Admin/Site.php +++ b/src/Module/Admin/Site.php @@ -177,7 +177,6 @@ class Site extends BaseAdmin $proxy = (!empty($_POST['proxy']) ? Strings::escapeTags(trim($_POST['proxy'])) : ''); $timeout = (!empty($_POST['timeout']) ? intval(trim($_POST['timeout'])) : 60); $maxloadavg = (!empty($_POST['maxloadavg']) ? intval(trim($_POST['maxloadavg'])) : 20); - $maxloadavg_frontend = (!empty($_POST['maxloadavg_frontend']) ? intval(trim($_POST['maxloadavg_frontend'])) : 50); $min_memory = (!empty($_POST['min_memory']) ? intval(trim($_POST['min_memory'])) : 0); $optimize_tables = (!empty($_POST['optimize_tables']) ? intval(trim($_POST['optimize_tables'])) : false); $contact_discovery = (!empty($_POST['contact_discovery']) ? intval(trim($_POST['contact_discovery'])) : Contact\Relation::DISCOVERY_NONE); @@ -264,7 +263,6 @@ class Site extends BaseAdmin } DI::config()->set('system', 'ssl_policy' , $ssl_policy); DI::config()->set('system', 'maxloadavg' , $maxloadavg); - DI::config()->set('system', 'maxloadavg_frontend' , $maxloadavg_frontend); DI::config()->set('system', 'min_memory' , $min_memory); DI::config()->set('system', 'optimize_tables' , $optimize_tables); DI::config()->set('system', 'contact_discovery' , $contact_discovery); @@ -576,7 +574,6 @@ class Site extends BaseAdmin '$proxy' => ['proxy', DI::l10n()->t('Proxy URL'), DI::config()->get('system', 'proxy'), ''], '$timeout' => ['timeout', DI::l10n()->t('Network timeout'), DI::config()->get('system', 'curl_timeout'), DI::l10n()->t('Value is in seconds. Set to 0 for unlimited (not recommended).')], '$maxloadavg' => ['maxloadavg', DI::l10n()->t('Maximum Load Average'), DI::config()->get('system', 'maxloadavg'), DI::l10n()->t('Maximum system load before delivery and poll processes are deferred - default %d.', 20)], - '$maxloadavg_frontend' => ['maxloadavg_frontend', DI::l10n()->t('Maximum Load Average (Frontend)'), DI::config()->get('system', 'maxloadavg_frontend'), DI::l10n()->t('Maximum system load before the frontend quits service - default 50.')], '$min_memory' => ['min_memory', DI::l10n()->t('Minimal Memory'), DI::config()->get('system', 'min_memory'), DI::l10n()->t('Minimal free memory in MB for the worker. Needs access to /proc/meminfo - default 0 (deactivated).')], '$optimize_tables' => ['optimize_tables', DI::l10n()->t('Periodically optimize tables'), DI::config()->get('system', 'optimize_tables'), DI::l10n()->t('Periodically optimize tables like the cache and the workerqueue')], diff --git a/static/settings.config.php b/static/settings.config.php index e3a7a10a2c..fd07c5d262 100644 --- a/static/settings.config.php +++ b/static/settings.config.php @@ -148,10 +148,6 @@ return [ // Maximum system load before delivery and poll processes are deferred. 'maxloadavg' => 20, - // maxloadavg_frontend (Integer) - // Maximum system load before the frontend quits service - default 50. - 'maxloadavg_frontend' => 50, - // min_memory (Integer) // Minimal free memory in MB for the worker. Needs access to /proc/meminfo - default 0 (deactivated). 'min_memory' => 0, diff --git a/view/templates/admin/site.tpl b/view/templates/admin/site.tpl index 985fa02221..6e2958b978 100644 --- a/view/templates/admin/site.tpl +++ b/view/templates/admin/site.tpl @@ -91,7 +91,6 @@ {{include file="field_input.tpl" field=$proxy}} {{include file="field_input.tpl" field=$proxyuser}} {{include file="field_input.tpl" field=$timeout}} - {{include file="field_input.tpl" field=$maxloadavg_frontend}} {{include file="field_input.tpl" field=$abandon_days}} {{include file="field_input.tpl" field=$temppath}} {{include file="field_checkbox.tpl" field=$suppress_tags}} diff --git a/view/theme/frio/templates/admin/site.tpl b/view/theme/frio/templates/admin/site.tpl index a6eb1d670f..e17dd57ac1 100644 --- a/view/theme/frio/templates/admin/site.tpl +++ b/view/theme/frio/templates/admin/site.tpl @@ -190,7 +190,6 @@ {{include file="field_input.tpl" field=$proxy}} {{include file="field_input.tpl" field=$proxyuser}} {{include file="field_input.tpl" field=$timeout}} - {{include file="field_input.tpl" field=$maxloadavg_frontend}} {{include file="field_input.tpl" field=$abandon_days}} {{include file="field_input.tpl" field=$temppath}} {{include file="field_checkbox.tpl" field=$suppress_tags}} -- 2.39.5