X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FWorker%2FCron.php;h=cd155dbbbe17b5e625533157737752445b4759c8;hb=a1d57abfe45d832aa36f9615eea35c6900c6f5b8;hp=270387d3551e8c983dca9b2eb07db477df4b7198;hpb=03af4062cedd55b55c40a6965120af9007bdf63f;p=friendica.git diff --git a/src/Worker/Cron.php b/src/Worker/Cron.php index 270387d355..cd155dbbbe 100644 --- a/src/Worker/Cron.php +++ b/src/Worker/Cron.php @@ -1,6 +1,6 @@ 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'); + Hook::fork(Worker::PRIORITY_MEDIUM, 'cron'); // Poll contacts - Worker::add(PRIORITY_MEDIUM, 'PollContacts'); + Worker::add(Worker::PRIORITY_MEDIUM, 'PollContacts'); // Update contact information - Worker::add(PRIORITY_LOW, 'UpdatePublicContacts'); + Worker::add(Worker::PRIORITY_LOW, 'UpdateContacts'); + + // Update server information + Worker::add(Worker::PRIORITY_LOW, 'UpdateGServers'); // run the process to update server directories in the background - Worker::add(PRIORITY_LOW, 'UpdateServerDirectories'); + Worker::add(Worker::PRIORITY_LOW, 'UpdateServerDirectories'); // Expire and remove user entries - Worker::add(PRIORITY_MEDIUM, 'ExpireAndRemoveUsers'); + Worker::add(Worker::PRIORITY_MEDIUM, 'ExpireAndRemoveUsers'); // Call possible post update functions - Worker::add(PRIORITY_LOW, 'PostUpdate'); + Worker::add(Worker::PRIORITY_LOW, 'PostUpdate'); // Hourly cron calls if (DI::config()->get('system', 'last_cron_hourly', 0) + 3600 < time()) { + // Update trending tags cache for the community page Tag::setLocalTrendingHashtags(24, 20); Tag::setGlobalTrendingHashtags(24, 20); + // Remove old pending posts from the queue + Queue::clear(); + + // Process all unprocessed entries + Queue::processAll(); + // Search for new contacts in the directory if (DI::config()->get('system', 'synchronize_directory')) { - Worker::add(PRIORITY_LOW, 'PullDirectory'); + Worker::add(Worker::PRIORITY_LOW, 'PullDirectory'); } - // Delete all done workerqueue entries - Worker::add(PRIORITY_LOW, 'CleanWorkerQueue'); - // Clear cache entries - Worker::add(PRIORITY_LOW, 'ClearCache'); + Worker::add(Worker::PRIORITY_LOW, 'ClearCache'); DI::config()->set('system', 'last_cron_hourly', time()); } @@ -96,35 +111,36 @@ class Cron // Daily maintenance cron calls if (Worker::isInMaintenanceWindow(true)) { - Worker::add(PRIORITY_LOW, 'UpdateContactBirthdays'); - - Worker::add(PRIORITY_LOW, 'UpdatePhotoAlbums'); + Worker::add(Worker::PRIORITY_LOW, 'UpdateContactBirthdays'); - // update nodeinfo data - Worker::add(PRIORITY_LOW, 'NodeInfo'); + Worker::add(Worker::PRIORITY_LOW, 'UpdatePhotoAlbums'); - Worker::add(PRIORITY_LOW, 'UpdateGServers'); + Worker::add(Worker::PRIORITY_LOW, 'ExpirePosts'); - // Repair entries in the database - Worker::add(PRIORITY_LOW, 'RepairDatabase'); + Worker::add(Worker::PRIORITY_LOW, 'ExpireActivities'); - Worker::add(PRIORITY_LOW, 'Expire'); + Worker::add(Worker::PRIORITY_LOW, 'RemoveUnusedTags'); - Worker::add(PRIORITY_LOW, 'ExpirePosts'); + Worker::add(Worker::PRIORITY_LOW, 'RemoveUnusedContacts'); - Worker::add(PRIORITY_LOW, 'ExpireConversations'); - - Worker::add(PRIORITY_LOW, 'CleanItemUri'); + Worker::add(Worker::PRIORITY_LOW, 'RemoveUnusedAvatars'); // check upstream version? - Worker::add(PRIORITY_LOW, 'CheckVersion'); + Worker::add(Worker::PRIORITY_LOW, 'CheckVersion'); - Worker::add(PRIORITY_LOW, 'CheckDeletedContacts'); + Worker::add(Worker::PRIORITY_LOW, 'CheckDeletedContacts'); if (DI::config()->get('system', 'optimize_tables')) { - Worker::add(PRIORITY_LOW, 'OptimizeTables'); + Worker::add(Worker::PRIORITY_LOW, 'OptimizeTables'); } - + + foreach (User::getList($start=1, $limit=PHP_INT_MAX, $type='active') as $user) { + Worker::add(Worker::PRIORITY_LOW, 'CheckRelMeProfileLink', $user['uid']); + } + + // Resubscribe to relay servers + Relay::reSubscribe(); + DI::config()->set('system', 'last_cron_daily', time()); } @@ -132,4 +148,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); + } }