]> git.mxchange.org Git - friendica.git/commitdiff
Separate config options to display the worker jobs per minute
authorMichael <heluecht@pirati.ca>
Wed, 6 Feb 2019 07:37:45 +0000 (07:37 +0000)
committerMichael <heluecht@pirati.ca>
Wed, 6 Feb 2019 07:37:45 +0000 (07:37 +0000)
config/defaults.config.php
src/Core/Worker.php

index 42533f5ad20f7db728976e1b7d2e38c4f0142ac8..18859ee103f9439bb7cb3bca7d40bbadfabb708f 100644 (file)
@@ -393,6 +393,10 @@ return [
                // Number of worker tasks that are fetched in a single query.
                'worker_fetch_limit' => 1,
 
+               // worker_jpm (Boolean)
+               // If enabled, it prints out the jobs per minute.
+               'worker_jpm' => false,
+
                // worker_load_exponent (Integer)
                // Default 3, which allows only 25% of the maximum worker queues when server load reaches around 37% of maximum load.
                // For a linear response where 25% of worker queues are allowed at 75% of maximum load, set this to 1.
index 00b22c78858c0b06c34ca643174b251fca5a5240..cd1627244337d99a8d2594b93139447aea2d9964 100644 (file)
@@ -657,6 +657,19 @@ class Worker
 
                        $processlist = '';
 
+                       if (Config::get('system', 'worker_jpm')) {
+                               $intervals = [1, 10, 60];
+                               $jobs_per_minute = [];
+                               foreach ($intervals as $interval) {
+                                       $jobs = DBA::p("SELECT COUNT(*) AS `jobs` FROM `workerqueue` WHERE `done` AND `executed` > UTC_TIMESTAMP() - INTERVAL ".intval($interval)." MINUTE");
+                                       if ($job = DBA::fetch($jobs)) {
+                                               $jobs_per_minute[$interval] = number_format($job['jobs'] / $interval, 0);
+                                       }
+                                       DBA::close($jobs);
+                               }
+                               $processlist = ' - jpm: '.implode('/', $jobs_per_minute);
+                       }
+
                        if (Config::get('system', 'worker_debug')) {
                                // Create a list of queue entries grouped by their priority
                                $listitem = [];
@@ -686,16 +699,7 @@ class Worker
                                }
                                DBA::close($entries);
 
-                               $intervals = [1, 10, 60];
-                               $jobs_per_minute = [];
-                               foreach ($intervals as $interval) {
-                                       $jobs = DBA::p("SELECT COUNT(*) AS `jobs` FROM `workerqueue` WHERE `done` AND `executed` > UTC_TIMESTAMP() - INTERVAL ".intval($interval)." MINUTE");
-                                       if ($job = DBA::fetch($jobs)) {
-                                               $jobs_per_minute[$interval] = number_format($job['jobs'] / $interval, 0);
-                                       }
-                                       DBA::close($jobs);
-                               }
-                               $processlist = ' - jpm: '.implode('/', $jobs_per_minute).' ('.implode(', ', $listitem).')';
+                               $processlist .= ' ('.implode(', ', $listitem).')';
                        }
 
                        $entries = self::totalEntries();