Configurable amount of maximum processes
This commit is contained in:
parent
140225b1a8
commit
b45772ba6e
|
@ -4,23 +4,24 @@ class dbm {
|
||||||
$r = q("SHOW PROCESSLIST");
|
$r = q("SHOW PROCESSLIST");
|
||||||
$s = array();
|
$s = array();
|
||||||
|
|
||||||
|
$processes = 0;
|
||||||
$states = array();
|
$states = array();
|
||||||
foreach ($r AS $process) {
|
foreach ($r AS $process) {
|
||||||
$state = trim($process["State"]);
|
$state = trim($process["State"]);
|
||||||
if (!in_array($state, array("", "init", "statistics")))
|
if (!in_array($state, array("", "init", "statistics"))) {
|
||||||
++$states[$state];
|
++$states[$state];
|
||||||
|
++$processes;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// query end
|
// query end
|
||||||
// Sending data
|
// Sending data
|
||||||
// updating
|
// updating
|
||||||
|
|
||||||
$statelist = "";
|
$statelist = "";
|
||||||
$processes = 0;
|
|
||||||
foreach ($states AS $state => $usage) {
|
foreach ($states AS $state => $usage) {
|
||||||
if ($statelist != "")
|
if ($statelist != "")
|
||||||
$statelist .= ", ";
|
$statelist .= ", ";
|
||||||
$statelist .= $state.": ".$usage;
|
$statelist .= $state.": ".$usage;
|
||||||
++$processes;
|
|
||||||
}
|
}
|
||||||
return(array("list" => $statelist, "amount" => $processes));
|
return(array("list" => $statelist, "amount" => $processes));
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,9 +29,16 @@ function poller_run(&$argv, &$argc){
|
||||||
|
|
||||||
$processlist = dbm::processlist();
|
$processlist = dbm::processlist();
|
||||||
if ($processlist["list"] != "") {
|
if ($processlist["list"] != "") {
|
||||||
logger("Processes: ".$processlist["amount"]." - Processlist: ".$processlist["list"], LOGGER_DEBUG);
|
logger("Processcheck: Processes: ".$processlist["amount"]." - Processlist: ".$processlist["list"], LOGGER_DEBUG);
|
||||||
if ($processlist["amount"] > 5)
|
|
||||||
|
$max_processes = get_config('system', 'max_processes_backend');
|
||||||
|
if (intval($max_processes) == 0)
|
||||||
|
$max_processes = 5;
|
||||||
|
|
||||||
|
if ($processlist["amount"] > $max_processes) {
|
||||||
|
logger("Processcheck: Maximum number of processes for backend tasks (".$max_processes.") reached.", LOGGER_DEBUG);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (poller_max_connections_reached())
|
if (poller_max_connections_reached())
|
||||||
|
@ -70,9 +77,16 @@ function poller_run(&$argv, &$argc){
|
||||||
// Log the type of database processes
|
// Log the type of database processes
|
||||||
$processlist = dbm::processlist();
|
$processlist = dbm::processlist();
|
||||||
if ($processlist["amount"] != "") {
|
if ($processlist["amount"] != "") {
|
||||||
logger("Processes: ".$processlist["amount"]." - Processlist: ".$processlist["list"], LOGGER_DEBUG);
|
logger("Processcheck: Processes: ".$processlist["amount"]." - Processlist: ".$processlist["list"], LOGGER_DEBUG);
|
||||||
if ($processlist["amount"] > 5)
|
|
||||||
|
$max_processes = get_config('system', 'max_processes_backend');
|
||||||
|
if (intval($max_processes) == 0)
|
||||||
|
$max_processes = 5;
|
||||||
|
|
||||||
|
if ($processlist["amount"] > $max_processes) {
|
||||||
|
logger("Processcheck: Maximum number of processes for backend tasks (".$max_processes.") reached.", LOGGER_DEBUG);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Constantly check the number of available database connections to let the frontend be accessible at any time
|
// Constantly check the number of available database connections to let the frontend be accessible at any time
|
||||||
|
|
23
index.php
23
index.php
|
@ -45,7 +45,7 @@ require_once("include/dbm.php");
|
||||||
|
|
||||||
if(!$install) {
|
if(!$install) {
|
||||||
$db = new dba($db_host, $db_user, $db_pass, $db_data, $install);
|
$db = new dba($db_host, $db_user, $db_pass, $db_data, $install);
|
||||||
unset($db_host, $db_user, $db_pass, $db_data);
|
unset($db_host, $db_user, $db_pass, $db_data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load configs from db. Overwrite configs from .htconfig.php
|
* Load configs from db. Overwrite configs from .htconfig.php
|
||||||
|
@ -56,12 +56,17 @@ if(!$install) {
|
||||||
|
|
||||||
$processlist = dbm::processlist();
|
$processlist = dbm::processlist();
|
||||||
if ($processlist["list"] != "") {
|
if ($processlist["list"] != "") {
|
||||||
logger("Processes: ".$processlist["amount"]." - Processlist: ".$processlist["list"], LOGGER_DEBUG);
|
|
||||||
|
|
||||||
// More than 20 running database processes?
|
logger("Processcheck: Processes: ".$processlist["amount"]." - Processlist: ".$processlist["list"], LOGGER_DEBUG);
|
||||||
// The system is too busy, so quit.
|
|
||||||
if ($processlist["amount"] > 20)
|
$max_processes = get_config('system', 'max_processes_frontend');
|
||||||
system_unavailable();
|
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);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$maxsysload_frontend = intval(get_config('system','maxloadavg_frontend'));
|
$maxsysload_frontend = intval(get_config('system','maxloadavg_frontend'));
|
||||||
|
@ -453,9 +458,9 @@ if($a->is_mobile || $a->is_tablet) {
|
||||||
$link = 'toggle_mobile?off=1&address=' . curPageURL();
|
$link = 'toggle_mobile?off=1&address=' . curPageURL();
|
||||||
}
|
}
|
||||||
$a->page['footer'] = replace_macros(get_markup_template("toggle_mobile_footer.tpl"), array(
|
$a->page['footer'] = replace_macros(get_markup_template("toggle_mobile_footer.tpl"), array(
|
||||||
'$toggle_link' => $link,
|
'$toggle_link' => $link,
|
||||||
'$toggle_text' => t('toggle mobile')
|
'$toggle_text' => t('toggle mobile')
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue
Block a user