]> git.mxchange.org Git - friendica.git/blobdiff - src/Core/Worker.php
Merge pull request #5038 from tobiasd/20180519-3834
[friendica.git] / src / Core / Worker.php
index 140d0e014d5f348aa7f910909bba5472639cc3e3..e3d8df45e40625eb2ce42b31d7328f6639f549f9 100644 (file)
@@ -201,7 +201,7 @@ class Worker
                $mypid = getmypid();
 
                // Quit when in maintenance
-               if (Config::get('system', 'maintenance', true)) {
+               if (Config::get('system', 'maintenance', false, true)) {
                        logger("Maintenance mode - quit process ".$mypid, LOGGER_DEBUG);
                        return false;
                }
@@ -325,6 +325,8 @@ class Worker
                        $a->performance["start"] = microtime(true);
                        $a->performance["database"] = 0;
                        $a->performance["database_write"] = 0;
+                       $a->performance["cache"] = 0;
+                       $a->performance["cache_write"] = 0;
                        $a->performance["network"] = 0;
                        $a->performance["file"] = 0;
                        $a->performance["rendering"] = 0;
@@ -389,9 +391,10 @@ class Worker
                if (Config::get("system", "profiler")) {
                        $duration = microtime(true)-$a->performance["start"];
 
+                       $o = '';
                        if (Config::get("rendertime", "callstack")) {
                                if (isset($a->callstack["database"])) {
-                                       $o = "\nDatabase Read:\n";
+                                       $o .= "\nDatabase Read:\n";
                                        foreach ($a->callstack["database"] as $func => $time) {
                                                $time = round($time, 3);
                                                if ($time > 0) {
@@ -408,6 +411,24 @@ class Worker
                                                }
                                        }
                                }
+                               if (isset($a->callstack["dache"])) {
+                                       $o .= "\nCache Read:\n";
+                                       foreach ($a->callstack["dache"] as $func => $time) {
+                                               $time = round($time, 3);
+                                               if ($time > 0) {
+                                                       $o .= $func.": ".$time."\n";
+                                               }
+                                       }
+                               }
+                               if (isset($a->callstack["dache_write"])) {
+                                       $o .= "\nCache Write:\n";
+                                       foreach ($a->callstack["dache_write"] as $func => $time) {
+                                               $time = round($time, 3);
+                                               if ($time > 0) {
+                                                       $o .= $func.": ".$time."\n";
+                                               }
+                                       }
+                               }
                                if (isset($a->callstack["network"])) {
                                        $o .= "\nNetwork:\n";
                                        foreach ($a->callstack["network"] as $func => $time) {
@@ -417,18 +438,20 @@ class Worker
                                                }
                                        }
                                }
-                       } else {
-                               $o = '';
                        }
 
                        logger(
                                "ID ".$queue["id"].": ".$funcname.": ".sprintf(
-                                       "DB: %s/%s, Net: %s, I/O: %s, Other: %s, Total: %s".$o,
+                                       "DB: %s/%s, Cache: %s/%s, Net: %s, I/O: %s, Other: %s, Total: %s".$o,
                                        number_format($a->performance["database"] - $a->performance["database_write"], 2),
                                        number_format($a->performance["database_write"], 2),
+                                       number_format($a->performance["cache"], 2),
+                                       number_format($a->performance["cache_write"], 2),
                                        number_format($a->performance["network"], 2),
                                        number_format($a->performance["file"], 2),
-                                       number_format($duration - ($a->performance["database"] + $a->performance["network"] + $a->performance["file"]), 2),
+                                       number_format($duration - ($a->performance["database"]
+                                               + $a->performance["cache"] + $a->performance["cache_write"]
+                                               + $a->performance["network"] + $a->performance["file"]), 2),
                                        number_format($duration, 2)
                                ),
                                LOGGER_DEBUG
@@ -564,6 +587,7 @@ class Worker
                                        // We killed the stale process.
                                        // To avoid a blocking situation we reschedule the process at the beginning of the queue.
                                        // Additionally we are lowering the priority. (But not PRIORITY_CRITICAL)
+                                       $new_priority = $entry["priority"];
                                        if ($entry["priority"] == PRIORITY_HIGH) {
                                                $new_priority = PRIORITY_MEDIUM;
                                        } elseif ($entry["priority"] == PRIORITY_MEDIUM) {
@@ -768,7 +792,7 @@ class Worker
                $limit = min($queue_length, ceil($slope * pow($jobs, $exponent)));
 
                logger('Total: '.$jobs.' - Maximum: '.$queue_length.' - jobs per queue: '.$limit, LOGGER_DEBUG);
-
+               $ids = [];
                if (self::passingSlow($highest_priority)) {
                        // Are there waiting processes with a higher priority than the currently highest?
                        $result = dba::select(
@@ -979,7 +1003,7 @@ class Worker
         */
        public static function spawnWorker()
        {
-               $args = ["scripts/worker.php", "no_cron"];
+               $args = ["bin/worker.php", "no_cron"];
                get_app()->proc_run($args);
        }