]> git.mxchange.org Git - friendica.git/blobdiff - src/Worker/Cron.php
Changed worker order
[friendica.git] / src / Worker / Cron.php
index be102bca8cb5f5a52aea3afa069c74312f76b273..a0144e8a2652003224b60d5531a89439beeca2d7 100644 (file)
@@ -24,6 +24,7 @@ namespace Friendica\Worker;
 use Friendica\Core\Hook;
 use Friendica\Core\Logger;
 use Friendica\Core\Worker;
+use Friendica\Database\DBA;
 use Friendica\DI;
 use Friendica\Model\Tag;
 
@@ -54,6 +55,10 @@ class Cron
                        copy($basepath . '/.htaccess-dist', $basepath . '/.htaccess');
                }
 
+               if (DI::config()->get('system', 'delete_sleeping_processes')) {
+                       self::deleteSleepingProcesses();
+               }
+
                // Fork the cron jobs in separate parts to avoid problems when one of them is crashing
                Hook::fork(PRIORITY_MEDIUM, 'cron');
 
@@ -103,22 +108,14 @@ class Cron
 
                        Worker::add(PRIORITY_LOW, 'UpdatePhotoAlbums');
 
-                       // update nodeinfo data
-                       Worker::add(PRIORITY_LOW, 'NodeInfo');
-
-                       // Repair entries in the database
-                       Worker::add(PRIORITY_LOW, 'RepairDatabase');
-
-                       Worker::add(PRIORITY_LOW, 'Expire');
-
                        Worker::add(PRIORITY_LOW, 'ExpirePosts');
 
                        Worker::add(PRIORITY_LOW, 'ExpireConversations');
 
-                       Worker::add(PRIORITY_LOW, 'CleanItemUri');
-
                        Worker::add(PRIORITY_LOW, 'RemoveUnusedContacts');
 
+                       Worker::add(PRIORITY_LOW, 'RemoveUnusedAvatars');
+
                        // check upstream version?
                        Worker::add(PRIORITY_LOW, 'CheckVersion');
 
@@ -135,4 +132,25 @@ class Cron
 
                DI::config()->set('system', 'last_cron', time());
        }
+
+       /**
+        * Kill sleeping database processes
+        *
+        * @return void
+        */
+       private static function deleteSleepingProcesses()
+       {
+               Logger::info('Looking for sleeping processes');
+               
+               $processes = DBA::p("SHOW FULL PROCESSLIST");
+               while ($process = DBA::fetch($processes)) {
+                       if (($process['Command'] != 'Sleep') || ($process['Time'] < 300) || ($process['db'] != DBA::databaseName())) {
+                               continue;
+                       }
+
+                       DBA::e("KILL ?", $process['Id']);
+                       Logger::notice('Killed sleeping process', ['id' => $process['Id']]);
+               }
+               DBA::close($processes);
+       }
 }