The priority is now a class constant
This commit is contained in:
parent
b33b70f0ab
commit
018858934b
46 changed files with 148 additions and 151 deletions
|
@ -34,7 +34,7 @@ class CheckDeletedContacts
|
|||
{
|
||||
$contacts = DBA::select('contact', ['id'], ['deleted' => true]);
|
||||
while ($contact = DBA::fetch($contacts)) {
|
||||
Worker::add(PRIORITY_MEDIUM, 'Contact\Remove', $contact['id']);
|
||||
Worker::add(Worker::PRIORITY_MEDIUM, 'Contact\Remove', $contact['id']);
|
||||
}
|
||||
DBA::close($contacts);
|
||||
}
|
||||
|
|
|
@ -62,25 +62,25 @@ class Cron
|
|||
}
|
||||
|
||||
// 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, 'UpdateContacts');
|
||||
Worker::add(Worker::PRIORITY_LOW, 'UpdateContacts');
|
||||
|
||||
// Update server information
|
||||
Worker::add(PRIORITY_LOW, 'UpdateGServers');
|
||||
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()) {
|
||||
|
@ -97,11 +97,11 @@ class Cron
|
|||
|
||||
// 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');
|
||||
}
|
||||
|
||||
// Clear cache entries
|
||||
Worker::add(PRIORITY_LOW, 'ClearCache');
|
||||
Worker::add(Worker::PRIORITY_LOW, 'ClearCache');
|
||||
|
||||
DI::config()->set('system', 'last_cron_hourly', time());
|
||||
}
|
||||
|
@ -109,27 +109,27 @@ class Cron
|
|||
// Daily maintenance cron calls
|
||||
if (Worker::isInMaintenanceWindow(true)) {
|
||||
|
||||
Worker::add(PRIORITY_LOW, 'UpdateContactBirthdays');
|
||||
Worker::add(Worker::PRIORITY_LOW, 'UpdateContactBirthdays');
|
||||
|
||||
Worker::add(PRIORITY_LOW, 'UpdatePhotoAlbums');
|
||||
Worker::add(Worker::PRIORITY_LOW, 'UpdatePhotoAlbums');
|
||||
|
||||
Worker::add(PRIORITY_LOW, 'ExpirePosts');
|
||||
Worker::add(Worker::PRIORITY_LOW, 'ExpirePosts');
|
||||
|
||||
Worker::add(PRIORITY_LOW, 'ExpireActivities');
|
||||
Worker::add(Worker::PRIORITY_LOW, 'ExpireActivities');
|
||||
|
||||
Worker::add(PRIORITY_LOW, 'RemoveUnusedTags');
|
||||
Worker::add(Worker::PRIORITY_LOW, 'RemoveUnusedTags');
|
||||
|
||||
Worker::add(PRIORITY_LOW, 'RemoveUnusedContacts');
|
||||
Worker::add(Worker::PRIORITY_LOW, 'RemoveUnusedContacts');
|
||||
|
||||
Worker::add(PRIORITY_LOW, 'RemoveUnusedAvatars');
|
||||
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');
|
||||
}
|
||||
|
||||
// Resubscribe to relay servers
|
||||
|
|
|
@ -64,7 +64,7 @@ class Directory
|
|||
private static function updateAll() {
|
||||
$users = DBA::select('owner-view', ['url'], ['net-publish' => true, 'account_expired' => false, 'verified' => true]);
|
||||
while ($user = DBA::fetch($users)) {
|
||||
Worker::add(PRIORITY_LOW, 'Directory', $user['url']);
|
||||
Worker::add(Worker::PRIORITY_LOW, 'Directory', $user['url']);
|
||||
}
|
||||
DBA::close($users);
|
||||
}
|
||||
|
|
|
@ -53,10 +53,10 @@ class ExpirePosts
|
|||
}
|
||||
|
||||
// Set the expiry for origin posta
|
||||
Worker::add(PRIORITY_LOW, 'Expire');
|
||||
Worker::add(Worker::PRIORITY_LOW, 'Expire');
|
||||
|
||||
// update nodeinfo data after everything is cleaned up
|
||||
Worker::add(PRIORITY_LOW, 'NodeInfo');
|
||||
Worker::add(Worker::PRIORITY_LOW, 'NodeInfo');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -37,7 +37,7 @@ class MoveStorage
|
|||
$moved = DI::storageManager()->move($current);
|
||||
|
||||
if ($moved) {
|
||||
Worker::add(PRIORITY_LOW, 'MoveStorage');
|
||||
Worker::add(Worker::PRIORITY_LOW, 'MoveStorage');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,7 +86,7 @@ class Notifier
|
|||
foreach ($inboxes as $inbox => $receivers) {
|
||||
$ap_contacts = array_merge($ap_contacts, $receivers);
|
||||
Logger::info('Delivery via ActivityPub', ['cmd' => $cmd, 'target' => $target_id, 'inbox' => $inbox]);
|
||||
Worker::add(['priority' => PRIORITY_HIGH, 'created' => $a->getQueueValue('created'), 'dont_fork' => true],
|
||||
Worker::add(['priority' => Worker::PRIORITY_HIGH, 'created' => $a->getQueueValue('created'), 'dont_fork' => true],
|
||||
'APDelivery', $cmd, $target_id, $inbox, $uid, $receivers, $post_uriid);
|
||||
}
|
||||
} elseif ($cmd == Delivery::SUGGESTION) {
|
||||
|
@ -568,7 +568,7 @@ class Notifier
|
|||
// Situation is that sometimes Friendica servers receive Friendica posts over the Diaspora protocol first.
|
||||
// The conversion in Markdown reduces the formatting, so these posts should arrive after the Friendica posts.
|
||||
// This is only important for high and medium priority tasks and not for Low priority jobs like deletions.
|
||||
if (($contact['network'] == Protocol::DIASPORA) && in_array($a->getQueueValue('priority'), [PRIORITY_HIGH, PRIORITY_MEDIUM])) {
|
||||
if (($contact['network'] == Protocol::DIASPORA) && in_array($a->getQueueValue('priority'), [Worker::PRIORITY_HIGH, Worker::PRIORITY_MEDIUM])) {
|
||||
$deliver_options = ['priority' => $a->getQueueValue('priority'), 'dont_fork' => true];
|
||||
} else {
|
||||
$deliver_options = ['priority' => $a->getQueueValue('priority'), 'created' => $a->getQueueValue('created'), 'dont_fork' => true];
|
||||
|
@ -698,7 +698,7 @@ class Notifier
|
|||
$inboxes = ActivityPub\Transmitter::fetchTargetInboxesforUser($self_user_id);
|
||||
foreach ($inboxes as $inbox => $receivers) {
|
||||
Logger::info('Account removal via ActivityPub', ['uid' => $self_user_id, 'inbox' => $inbox]);
|
||||
Worker::add(['priority' => PRIORITY_NEGLIGIBLE, 'created' => $created, 'dont_fork' => true],
|
||||
Worker::add(['priority' => Worker::PRIORITY_NEGLIGIBLE, 'created' => $created, 'dont_fork' => true],
|
||||
'APDelivery', Delivery::REMOVAL, 0, $inbox, $self_user_id, $receivers);
|
||||
Worker::coolDown();
|
||||
}
|
||||
|
@ -817,7 +817,7 @@ class Notifier
|
|||
if (DI::config()->get('system', 'bulk_delivery')) {
|
||||
$delivery_queue_count++;
|
||||
Post\Delivery::add($target_item['uri-id'], $uid, $inbox, $target_item['created'], $cmd, $receivers);
|
||||
Worker::add(PRIORITY_HIGH, 'APDelivery', '', 0, $inbox, 0);
|
||||
Worker::add(Worker::PRIORITY_HIGH, 'APDelivery', '', 0, $inbox, 0);
|
||||
} else {
|
||||
if (Worker::add(['priority' => $priority, 'created' => $created, 'dont_fork' => true],
|
||||
'APDelivery', $cmd, $target_item['id'], $inbox, $uid, $receivers, $target_item['uri-id'])) {
|
||||
|
@ -834,7 +834,7 @@ class Notifier
|
|||
if (DI::config()->get('system', 'bulk_delivery')) {
|
||||
$delivery_queue_count++;
|
||||
Post\Delivery::add($target_item['uri-id'], $uid, $inbox, $target_item['created'], $cmd, []);
|
||||
Worker::add(PRIORITY_MEDIUM, 'APDelivery', '', 0, $inbox, 0);
|
||||
Worker::add(Worker::PRIORITY_MEDIUM, 'APDelivery', '', 0, $inbox, 0);
|
||||
} else {
|
||||
if (Worker::add(['priority' => $priority, 'dont_fork' => true], 'APDelivery', $cmd, $target_item['id'], $inbox, $uid, [], $target_item['uri-id'])) {
|
||||
$delivery_queue_count++;
|
||||
|
|
|
@ -71,11 +71,11 @@ class PollContacts
|
|||
}
|
||||
|
||||
if ((($contact['network'] == Protocol::FEED) && ($contact['priority'] <= 3)) || ($contact['network'] == Protocol::MAIL)) {
|
||||
$priority = PRIORITY_MEDIUM;
|
||||
$priority = Worker::PRIORITY_MEDIUM;
|
||||
} elseif ($contact['archive']) {
|
||||
$priority = PRIORITY_NEGLIGIBLE;
|
||||
$priority = Worker::PRIORITY_NEGLIGIBLE;
|
||||
} else {
|
||||
$priority = PRIORITY_LOW;
|
||||
$priority = Worker::PRIORITY_LOW;
|
||||
}
|
||||
|
||||
Logger::notice("Polling " . $contact["network"] . " " . $contact["id"] . " " . $contact['priority'] . " " . $contact["nick"] . " " . $contact["name"]);
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
namespace Friendica\Worker;
|
||||
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\Post;
|
||||
|
@ -48,7 +49,7 @@ class RemoveUser {
|
|||
do {
|
||||
$items = Post::select(['id'], $condition, ['limit' => 100]);
|
||||
while ($item = Post::fetch($items)) {
|
||||
Item::markForDeletionById($item['id'], PRIORITY_NEGLIGIBLE);
|
||||
Item::markForDeletionById($item['id'], Worker::PRIORITY_NEGLIGIBLE);
|
||||
}
|
||||
DBA::close($items);
|
||||
} while (Post::exists($condition));
|
||||
|
|
|
@ -59,7 +59,7 @@ class UpdateContacts
|
|||
$contacts = DBA::select('contact', ['id'], $condition, ['order' => ['next-update'], 'limit' => $limit]);
|
||||
$count = 0;
|
||||
while ($contact = DBA::fetch($contacts)) {
|
||||
if (Worker::add(['priority' => PRIORITY_LOW, 'dont_fork' => true], "UpdateContact", $contact['id'])) {
|
||||
if (Worker::add(['priority' => Worker::PRIORITY_LOW, 'dont_fork' => true], "UpdateContact", $contact['id'])) {
|
||||
++$count;
|
||||
}
|
||||
Worker::coolDown();
|
||||
|
|
|
@ -63,12 +63,12 @@ class UpdateGServers
|
|||
// There are duplicated "url" but not "nurl". So we check both addresses instead of just overwriting them,
|
||||
// since that would mean loosing data.
|
||||
if (!empty($gserver['url'])) {
|
||||
if (Worker::add(PRIORITY_LOW, 'UpdateGServer', $gserver['url'])) {
|
||||
if (Worker::add(Worker::PRIORITY_LOW, 'UpdateGServer', $gserver['url'])) {
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
if (!empty($gserver['nurl']) && ($gserver['nurl'] != Strings::normaliseLink($gserver['url']))) {
|
||||
if (Worker::add(PRIORITY_LOW, 'UpdateGServer', $gserver['nurl'])) {
|
||||
if (Worker::add(Worker::PRIORITY_LOW, 'UpdateGServer', $gserver['nurl'])) {
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue