]> git.mxchange.org Git - friendica.git/blobdiff - src/Core/Worker.php
NL translation update THX casperrutten33
[friendica.git] / src / Core / Worker.php
index f4df3224928b539636b48b2602708b90698e8b95..7758e06a90b9e838a225bd1ceda277087fe1ed1a 100644 (file)
@@ -91,12 +91,13 @@ class Worker
                        self::runCron();
                }
 
-               $starttime = time();
+               $last_check = $starttime = time();
                self::$state = self::STATE_STARTUP;
 
                // We fetch the next queue entry that is about to be executed
                while ($r = self::workerProcess()) {
-                       $refetched = false;
+                       // Don't refetch when a worker fetches tasks for multiple workers
+                       $refetched = DI::config()->get('system', 'worker_multiple_fetch');
                        foreach ($r as $entry) {
                                // Assure that the priority is an integer value
                                $entry['priority'] = (int)$entry['priority'];
@@ -119,7 +120,7 @@ class Worker
                        }
 
                        // To avoid the quitting of multiple workers only one worker at a time will execute the check
-                       if (!self::getWaitingJobForPID()) {
+                       if ((time() > $last_check + 5) && !self::getWaitingJobForPID()) {
                                self::$state = self::STATE_LONG_LOOP;
 
                                if (DI::lock()->acquire(self::LOCK_WORKER, 0)) {
@@ -138,11 +139,13 @@ class Worker
                                        }
                                        DI::lock()->release(self::LOCK_WORKER);
                                }
+                               $last_check = time();
                        }
 
                        // Quit the worker once every cron interval
                        if (time() > ($starttime + (DI::config()->get('system', 'cron_interval') * 60))) {
                                Logger::info('Process lifetime reached, respawning.');
+                               self::unclaimProcess();
                                self::spawnWorker();
                                return;
                        }
@@ -782,6 +785,7 @@ class Worker
                $stamp = (float)microtime(true);
                $count = DBA::count('process', ['command' => 'Worker.php']);
                self::$db_duration += (microtime(true) - $stamp);
+               self::$db_duration_count += (microtime(true) - $stamp);
                return $count;
        }
 
@@ -805,6 +809,7 @@ class Worker
                DBA::close($queues);
 
                self::$db_duration += (microtime(true) - $stamp);
+               self::$db_duration_count += (microtime(true) - $stamp);
                return $ids;
        }