};
// Quit when in maintenance
- if (get_config('system', 'maintenance', true))
+ if (Config::get('system', 'maintenance', true)) {
return;
+ }
$a->start_process();
$cooldown = Config::get("system", "worker_cooldown", 0);
// Quit when in maintenance
- if (get_config('system', 'maintenance', true)) {
+ if (Config::get('system', 'maintenance', true)) {
return false;
}
if (function_exists($funcname)) {
+ logger("Process ".$mypid." - Prio ".$queue["priority"]." - ID ".$queue["id"].": ".$funcname." ".$queue["parameter"]);
+
$stamp = (float)microtime(true);
- if (get_config("system", "profiler")) {
+ if (Config::get("system", "profiler")) {
$a->performance["start"] = microtime(true);
$a->performance["database"] = 0;
$a->performance["database_write"] = 0;
$a->callstack = array();
}
- logger("Process ".$mypid." - Prio ".$queue["priority"]." - ID ".$queue["id"].": ".$funcname." ".$queue["parameter"]);
-
// For better logging create a new process id for every worker call
// But preserve the old one for the worker
$old_process_id = $a->process_id;
$a->process_id = $old_process_id;
- if ($cooldown > 0) {
- logger("Process ".$mypid." - Prio ".$queue["priority"]." - ID ".$queue["id"].": ".$funcname." - in cooldown for ".$cooldown." seconds");
- sleep($cooldown);
- }
-
$duration = number_format(microtime(true) - $stamp, 3);
logger("Process ".$mypid." - Prio ".$queue["priority"]." - ID ".$queue["id"].": ".$funcname." - done in ".$duration." seconds.");
- if (get_config("system", "profiler")) {
+ if (Config::get("system", "profiler")) {
$duration = microtime(true)-$a->performance["start"];
logger("ID ".$queue["id"].": ".$funcname.": ".sprintf("DB: %s/%s, Net: %s, I/O: %s, Other: %s, Total: %s",
number_format($duration, 2)),
LOGGER_DEBUG);
- if (get_config("rendertime", "callstack")) {
+ if (Config::get("rendertime", "callstack")) {
$o = "ID ".$queue["id"].": ".$funcname.": Database Read:\n";
foreach ($a->callstack["database"] AS $func => $time) {
$time = round($time, 3);
}
}
+ if ($cooldown > 0) {
+ logger("Process ".$mypid." - Prio ".$queue["priority"]." - ID ".$queue["id"].": ".$funcname." - in cooldown for ".$cooldown." seconds");
+ sleep($cooldown);
+ }
+
q("DELETE FROM `workerqueue` WHERE `id` = %d", intval($queue["id"]));
} else {
logger("Function ".$funcname." does not exist");
function poller_max_connections_reached() {
// Fetch the max value from the config. This is needed when the system cannot detect the correct value by itself.
- $max = get_config("system", "max_connections");
+ $max = Config::get("system", "max_connections");
// Fetch the percentage level where the poller will get active
$maxlevel = Config::get("system", "max_connections_level", 75);
logger("Load: ".$load."/".$maxsysload." - processes: ".$active."/".$entries." (".$processlist.") - maximum: ".$queues."/".$maxqueues, LOGGER_DEBUG);
// Are there fewer workers running as possible? Then fork a new one.
- if (!get_config("system", "worker_dont_fork") AND ($queues > ($active + 1)) AND ($entries > 1)) {
+ if (!Config::get("system", "worker_dont_fork") AND ($queues > ($active + 1)) AND ($entries > 1)) {
logger("Active workers: ".$active."/".$queues." Fork a new worker.", LOGGER_DEBUG);
$args = array("php", "include/poller.php", "no_cron");
$a = get_app();
if (function_exists("proc_open")) {
// When was the last time that we called the worker?
// Less than one minute? Then we quit
- if ((time() - get_config("system", "worker_started")) < 60) {
+ if ((time() - Config::get("system", "worker_started")) < 60) {
return;
}