- $processlist = dbm::processlist();
- if ($processlist["list"] != "") {
-
- logger("Processcheck: Processes: ".$processlist["amount"]." - Processlist: ".$processlist["list"], LOGGER_DEBUG);
-
- $max_processes = get_config('system', 'max_processes_frontend');
- if (intval($max_processes) == 0)
- $max_processes = 20;
-
- if ($processlist["amount"] > $max_processes) {
- logger("Processcheck: Maximum number of processes for frontend tasks (".$max_processes.") reached.", LOGGER_DEBUG);
- system_unavailable();
- }
- }
-
- $maxsysload_frontend = intval(get_config('system','maxloadavg_frontend'));
- if($maxsysload_frontend < 1)
- $maxsysload_frontend = 50;
-
- $load = current_load();
- if($load) {
- if($load > $maxsysload_frontend) {
- logger('system: load ' . $load . ' 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 ($a->max_processes_reached() OR $a->maxload_reached()) {
+ header($_SERVER["SERVER_PROTOCOL"].' 503 Service Temporarily Unavailable');
+ header('Retry-After: 120');
+ header('Refresh: 120; url='.App::get_baseurl()."/".$a->query_string);
+ die("System is currently unavailable. Please try again later");