diff options
Diffstat (limited to 'Zotlabs/Daemon')
-rw-r--r-- | Zotlabs/Daemon/Addon.php | 1 | ||||
-rw-r--r-- | Zotlabs/Daemon/Cache_embeds.php | 4 | ||||
-rw-r--r-- | Zotlabs/Daemon/Cache_query.php | 4 | ||||
-rw-r--r-- | Zotlabs/Daemon/Cli_suggest.php | 1 | ||||
-rw-r--r-- | Zotlabs/Daemon/Convo.php | 31 | ||||
-rw-r--r-- | Zotlabs/Daemon/Cron.php | 30 | ||||
-rw-r--r-- | Zotlabs/Daemon/Cron_daily.php | 18 | ||||
-rw-r--r-- | Zotlabs/Daemon/Cron_weekly.php | 11 | ||||
-rw-r--r-- | Zotlabs/Daemon/Deliver.php | 2 | ||||
-rw-r--r-- | Zotlabs/Daemon/Deliver_hooks.php | 6 | ||||
-rw-r--r-- | Zotlabs/Daemon/Directory.php | 2 | ||||
-rw-r--r-- | Zotlabs/Daemon/Expire.php | 2 | ||||
-rw-r--r-- | Zotlabs/Daemon/Externals.php | 8 | ||||
-rw-r--r-- | Zotlabs/Daemon/Importdoc.php | 2 | ||||
-rw-r--r-- | Zotlabs/Daemon/Master.php | 12 | ||||
-rw-r--r-- | Zotlabs/Daemon/Notifier.php | 12 | ||||
-rw-r--r-- | Zotlabs/Daemon/Onepoll.php | 13 | ||||
-rw-r--r-- | Zotlabs/Daemon/Poller.php | 41 | ||||
-rw-r--r-- | Zotlabs/Daemon/Queue.php | 2 | ||||
-rw-r--r-- | Zotlabs/Daemon/Thumbnail.php | 2 |
20 files changed, 148 insertions, 56 deletions
diff --git a/Zotlabs/Daemon/Addon.php b/Zotlabs/Daemon/Addon.php index c6778750d..126e11cf6 100644 --- a/Zotlabs/Daemon/Addon.php +++ b/Zotlabs/Daemon/Addon.php @@ -7,6 +7,7 @@ class Addon { static public function run($argc, $argv) { call_hooks('daemon_addon', $argv); + return; } diff --git a/Zotlabs/Daemon/Cache_embeds.php b/Zotlabs/Daemon/Cache_embeds.php index 9e5b8d2bb..d5adfcc59 100644 --- a/Zotlabs/Daemon/Cache_embeds.php +++ b/Zotlabs/Daemon/Cache_embeds.php @@ -19,8 +19,10 @@ class Cache_embeds { $item = $c[0]; // bbcode conversion by default processes embeds that aren't already cached. - // Ignore the returned html output. + // Ignore the returned html output. bbcode($item['body']); + + return; } } diff --git a/Zotlabs/Daemon/Cache_query.php b/Zotlabs/Daemon/Cache_query.php index 5f92ae6d0..cd9597e9a 100644 --- a/Zotlabs/Daemon/Cache_query.php +++ b/Zotlabs/Daemon/Cache_query.php @@ -24,7 +24,7 @@ class Cache_query { array_shift($argv); array_shift($argv); - + $arr = json_decode(base64_decode($argv[0]), true); $r = call_user_func_array('q', $arr); @@ -32,5 +32,7 @@ class Cache_query { Cache::set($key, serialize($r)); del_config('procid', $key); + + return; } } diff --git a/Zotlabs/Daemon/Cli_suggest.php b/Zotlabs/Daemon/Cli_suggest.php index 5dced462d..028228cb0 100644 --- a/Zotlabs/Daemon/Cli_suggest.php +++ b/Zotlabs/Daemon/Cli_suggest.php @@ -9,6 +9,7 @@ class Cli_suggest { static public function run($argc,$argv) { update_suggestions(); + return; } } diff --git a/Zotlabs/Daemon/Convo.php b/Zotlabs/Daemon/Convo.php index 940216b2c..d1a7e4f4d 100644 --- a/Zotlabs/Daemon/Convo.php +++ b/Zotlabs/Daemon/Convo.php @@ -30,6 +30,7 @@ class Convo { intval($channel_id), dbesc($contact_hash) ); + if (!$r) { return; } @@ -40,19 +41,25 @@ class Convo { $messages = $obj->get(); - if ($messages) { - foreach ($messages as $message) { - if (is_string($message)) { - $message = Activity::fetch($message, $channel); - } - // set client flag because comments will probably just be objects and not full blown activities - // and that lets us use implied_create - $AS = new ActivityStreams($message); - if ($AS->is_valid() && is_array($AS->obj)) { - $item = Activity::decode_note($AS); - Activity::store($channel, $contact['abook_xchan'], $AS, $item); - } + if (!$messages) { + return; + } + + foreach ($messages as $message) { + if (is_string($message)) { + $message = Activity::fetch($message, $channel); + } + + // set client flag because comments will probably just be objects and not full blown activities + // and that lets us use implied_create + $AS = new ActivityStreams($message); + if ($AS->is_valid() && is_array($AS->obj)) { + $item = Activity::decode_note($AS); + Activity::store($channel, $contact['abook_xchan'], $AS, $item); } } + + return; + } } diff --git a/Zotlabs/Daemon/Cron.php b/Zotlabs/Daemon/Cron.php index 6629491de..640f06102 100644 --- a/Zotlabs/Daemon/Cron.php +++ b/Zotlabs/Daemon/Cron.php @@ -19,6 +19,7 @@ class Cron { } } +/* // Check for a lockfile. If it exists, but is over an hour old, it's stale. Ignore it. $lockfile = 'store/[data]/cron'; if ((file_exists($lockfile)) && (filemtime($lockfile) > (time() - 3600)) @@ -30,6 +31,7 @@ class Cron { // Create a lockfile. Needs two vars, but $x doesn't need to contain anything. $x = ''; file_put_contents($lockfile, $x); +*/ logger('cron: start'); @@ -50,7 +52,7 @@ class Cron { require_once('include/account.php'); remove_expired_registrations(); - $interval = get_config('system', 'delivery_interval', 3); + $interval = get_config('queueworker', 'queue_interval', 500000); // expire any expired items @@ -65,8 +67,10 @@ class Cron { if ($rr['item_wall']) { // The notifier isn't normally invoked unless item_drop is interactive. Master::Summon(['Notifier', 'drop', $rr['id']]); - if ($interval) - @time_sleep_until(microtime(true) + (float)$interval); + + if ($interval) { + usleep($interval); + } } } } @@ -96,8 +100,10 @@ class Cron { if ($r) { foreach ($r as $rr) { Master::Summon(array('Directory', $rr['channel_id'], 'force')); - if ($interval) - @time_sleep_until(microtime(true) + (float)$interval); + + if ($interval) { + usleep($interval); + } } } @@ -151,8 +157,10 @@ class Cron { ); } Master::Summon(array('Notifier', 'wall-new', $rr['id'])); - if ($interval) - @time_sleep_until(microtime(true) + (float)$interval); + + if ($interval) { + usleep($interval); + } } } } @@ -203,10 +211,10 @@ class Cron { } - // pull in some public posts + // pull in some public posts if allowed - $disable_discover_tab = get_config('system', 'disable_discover_tab') || get_config('system', 'disable_discover_tab') === false; - if (!$disable_discover_tab) + $disable_externals = get_config('system', 'disable_discover_tab') || get_config('system', 'disable_discover_tab') === false || get_config('system', 'site_firehose'); + if (!$disable_externals) Master::Summon(['Externals']); $restart = false; @@ -228,7 +236,7 @@ class Cron { set_config('system', 'lastcron', datetime_convert()); //All done - clear the lockfile - @unlink($lockfile); + //@unlink($lockfile); return; } diff --git a/Zotlabs/Daemon/Cron_daily.php b/Zotlabs/Daemon/Cron_daily.php index d1b74a032..6d62836c7 100644 --- a/Zotlabs/Daemon/Cron_daily.php +++ b/Zotlabs/Daemon/Cron_daily.php @@ -49,6 +49,22 @@ class Cron_daily { dbesc('sse_id.%') ); + // Mark items seen after X days (default 90) + + $r = dbq("select channel_id from channel where channel_removed = 0"); + if ($r) { + foreach ($r as $rr) { + $mark_seen_days = get_pconfig($rr['channel_id'], 'system', 'mark_seen_days', 90); + q("UPDATE item SET item_unseen = 0 WHERE + uid = %d AND item_unseen = 1 + AND created < %s - INTERVAL %s", + intval($rr['channel_id']), + db_utcnow(), + db_quoteinterval($mark_seen_days . ' DAY') + ); + } + } + // Clean up emdedded content cache q("DELETE FROM cache WHERE updated < %s - INTERVAL %s", db_utcnow(), @@ -103,5 +119,7 @@ class Cron_daily { /** * End Cron Daily */ + + return; } } diff --git a/Zotlabs/Daemon/Cron_weekly.php b/Zotlabs/Daemon/Cron_weekly.php index 407aa40ef..75fb94700 100644 --- a/Zotlabs/Daemon/Cron_weekly.php +++ b/Zotlabs/Daemon/Cron_weekly.php @@ -22,12 +22,12 @@ class Cron_weekly { mark_orphan_hubsxchans(); - // Find channels that were removed in the last three weeks, but + // Find channels that were removed in the last three weeks, but // haven't been finally cleaned up. These should be older than 10 - // days to ensure that "purgeall" messages have gone out or bounced - // or timed out. + // days to ensure that "purgeall" messages have gone out or bounced + // or timed out. - $r = q("select channel_id from channel where channel_removed = 1 and + $r = q("select channel_id from channel where channel_removed = 1 and channel_deleted > %s - INTERVAL %s and channel_deleted < %s - INTERVAL %s", db_utcnow(), db_quoteinterval('21 DAY'), db_utcnow(), db_quoteinterval('10 DAY') @@ -59,5 +59,6 @@ class Cron_weekly { * End Cron Weekly */ + return; } -}
\ No newline at end of file +} diff --git a/Zotlabs/Daemon/Deliver.php b/Zotlabs/Daemon/Deliver.php index 400ef697b..2d80dc093 100644 --- a/Zotlabs/Daemon/Deliver.php +++ b/Zotlabs/Daemon/Deliver.php @@ -28,6 +28,8 @@ class Deliver { } + return; + } } diff --git a/Zotlabs/Daemon/Deliver_hooks.php b/Zotlabs/Daemon/Deliver_hooks.php index 4d3ce4e1d..1e478db1e 100644 --- a/Zotlabs/Daemon/Deliver_hooks.php +++ b/Zotlabs/Daemon/Deliver_hooks.php @@ -12,8 +12,12 @@ class Deliver_hooks { $r = q("select * from item where id = '%d'", intval($argv[1]) ); - if ($r) + + if ($r) { call_hooks('notifier_normal', $r[0]); + } + + return; } } diff --git a/Zotlabs/Daemon/Directory.php b/Zotlabs/Daemon/Directory.php index 3996b8079..19adf8273 100644 --- a/Zotlabs/Daemon/Directory.php +++ b/Zotlabs/Daemon/Directory.php @@ -97,5 +97,7 @@ class Directory { if ($pushall) { Master::Summon(array('Notifier', 'refresh_all', $channel['channel_id'])); } + + return; } } diff --git a/Zotlabs/Daemon/Expire.php b/Zotlabs/Daemon/Expire.php index 99fe68b6f..5d9f14b28 100644 --- a/Zotlabs/Daemon/Expire.php +++ b/Zotlabs/Daemon/Expire.php @@ -103,5 +103,7 @@ class Expire { } del_config('procid', 'expire'); + + return; } } diff --git a/Zotlabs/Daemon/Externals.php b/Zotlabs/Daemon/Externals.php index 5b7954c2f..2c7c7c172 100644 --- a/Zotlabs/Daemon/Externals.php +++ b/Zotlabs/Daemon/Externals.php @@ -19,6 +19,7 @@ class Externals { $importer = get_sys_channel(); $total = 0; $attempts = 0; + $url = ''; logger('externals: startup', LOGGER_DEBUG); @@ -67,9 +68,8 @@ class Externals { datetime_convert('UTC', 'UTC', 'now - 30 days') ); - $contact = $r[0]; - - if ($contact) { + if ($r) { + $contact = $r[0]; $url = $contact['hubloc_id_url']; } } @@ -143,7 +143,7 @@ class Externals { $AS = new ActivityStreams($message); if ($AS->is_valid() && is_array($AS->obj)) { $item = Activity::decode_note($AS); - Activity::store($importer, $contact['abook_xchan'], $AS, $item); + Activity::store($importer, $contact['hubloc_hash'], $AS, $item); $total++; } } diff --git a/Zotlabs/Daemon/Importdoc.php b/Zotlabs/Daemon/Importdoc.php index 9e818e2b3..c5a81e50c 100644 --- a/Zotlabs/Daemon/Importdoc.php +++ b/Zotlabs/Daemon/Importdoc.php @@ -11,6 +11,8 @@ class Importdoc { self::update_docs_dir('doc/*'); + return; + } static public function update_docs_dir($s) { diff --git a/Zotlabs/Daemon/Master.php b/Zotlabs/Daemon/Master.php index 6fa656be5..c9ed91aaa 100644 --- a/Zotlabs/Daemon/Master.php +++ b/Zotlabs/Daemon/Master.php @@ -2,6 +2,8 @@ namespace Zotlabs\Daemon; +use Zotlabs\Lib\QueueWorker; + if (array_search(__file__, get_included_files()) === 0) { require_once('include/cli_startup.php'); array_shift($argv); @@ -9,6 +11,7 @@ if (array_search(__file__, get_included_files()) === 0) { if ($argc) Master::Release($argc, $argv); + return; } @@ -16,6 +19,10 @@ if (array_search(__file__, get_included_files()) === 0) { class Master { static public function Summon($arr) { + + QueueWorker::Summon($arr); + return; +/* $hookinfo = [ 'argv' => $arr ]; @@ -32,11 +39,15 @@ class Master { $phpbin = get_config('system', 'phpbin', 'php'); proc_run($phpbin, 'Zotlabs/Daemon/Master.php', $arr); +*/ } static public function Release($argc, $argv) { cli_startup(); + QueueWorker::Release($argv); + return; +/* $hookinfo = [ 'argv' => $argv ]; @@ -54,5 +65,6 @@ class Master { logger('Master: release: ' . json_encode($argv), LOGGER_ALL, LOG_DEBUG); $cls = '\\Zotlabs\\Daemon\\' . $argv[0]; $cls::run($argc, $argv); +*/ } } diff --git a/Zotlabs/Daemon/Notifier.php b/Zotlabs/Daemon/Notifier.php index bfccb4099..de8597081 100644 --- a/Zotlabs/Daemon/Notifier.php +++ b/Zotlabs/Daemon/Notifier.php @@ -79,10 +79,7 @@ class Notifier { static public $encoded_item = null; static public $channel = null; static public $private = false; - // $fragment can contain additional info to omit de-duplication in the queueworker. - // E.g. if an item is updated many times in a row from different sources (multiple vote updates) the - // update source mid or a timestamp or random string can be added. - static public $fragment = null; + static public function run($argc, $argv) { @@ -107,7 +104,6 @@ class Notifier { self::$encoded_item = null; self::$channel = null; self::$private = false; - self::$fragment = null; $sys = get_sys_channel(); $normal_mode = true; @@ -233,8 +229,6 @@ class Notifier { // Fetch the target item - self::$fragment = $argv[3] ?? ''; - $r = q("SELECT * FROM item WHERE id = %d AND parent != 0", intval($item_id) ); @@ -509,6 +503,7 @@ class Notifier { // public posts won't make it to the local public stream unless there's a recipient on this site. // This code block sees if it's a public post and localhost is missing, and if so adds an entry for the local sys channel to the $hubs list + /* sys channel is now added in collect recipients if (!self::$private) { $found_localhost = false; if ($hubs) { @@ -529,6 +524,7 @@ class Notifier { } } } + */ if (!$hubs) { logger('notifier: no hubs', LOGGER_NORMAL, LOG_NOTICE); @@ -699,7 +695,7 @@ class Notifier { // This wastes a process if there are no delivery hooks configured, so check this before launching the new process $x = q("select * from hook where hook = 'notifier_normal'"); if ($x) { - Master::Summon(['Deliver_hooks', $target_item['id'], self::$fragment]); + Master::Summon(['Deliver_hooks', $target_item['id']]); } } diff --git a/Zotlabs/Daemon/Onepoll.php b/Zotlabs/Daemon/Onepoll.php index f2b5d8c58..0a30a0c7d 100644 --- a/Zotlabs/Daemon/Onepoll.php +++ b/Zotlabs/Daemon/Onepoll.php @@ -64,12 +64,21 @@ class Onepoll { if ($contact['xchan_network'] === 'rss') { logger('onepoll: processing feed ' . $contact['xchan_name'], LOGGER_DEBUG); $alive = handle_feed($importer['channel_id'], $contact_id, $contact['xchan_hash']); - if ($alive) { - q("update abook set abook_connected = '%s' where abook_id = %d", + + if (!$alive) { + q("update abook set abook_updated = '%s' where abook_id = %d", dbesc(datetime_convert()), intval($contact['abook_id']) ); + return; } + + q("update abook set abook_updated = '%s', abook_connected = '%s' where abook_id = %d", + dbesc(datetime_convert()), + dbesc(datetime_convert()), + intval($contact['abook_id']) + ); + return; } diff --git a/Zotlabs/Daemon/Poller.php b/Zotlabs/Daemon/Poller.php index 88213a7c9..0fdc3da16 100644 --- a/Zotlabs/Daemon/Poller.php +++ b/Zotlabs/Daemon/Poller.php @@ -17,9 +17,12 @@ class Poller { } } - $interval = intval(get_config('system', 'poll_interval')); - if (!$interval) + $interval = get_config('queueworker', 'queue_interval', 500000); + +/* + if (!$interval) { $interval = ((get_config('system', 'delivery_interval') === false) ? 3 : intval(get_config('system', 'delivery_interval'))); + } // Check for a lockfile. If it exists, but is over an hour old, it's stale. Ignore it. $lockfile = 'store/[data]/poller'; @@ -32,6 +35,7 @@ class Poller { // Create a lockfile. Needs two vars, but $x doesn't need to contain anything. $x = ''; file_put_contents($lockfile, $x); +*/ logger('poller: start'); @@ -93,13 +97,24 @@ class Poller { $min = intval(get_config('system', 'minimum_feedcheck_minutes')); if (!$min) $min = 60; + + if ($t !== $c) { + // if the last fetch failed only attempt fetch once a day + $min = 60 * 24; + } + $x = datetime_convert('UTC', 'UTC', "now - $min minutes"); - if ($c < $x) { + + if ($t < $x) { Master::Summon(['Onepoll', $contact['abook_id']]); - if ($interval) - @time_sleep_until(microtime(true) + (float)$interval); + + if ($interval) { + usleep($interval); + } } + continue; + } if ($contact['xchan_network'] !== 'zot6') @@ -158,9 +173,10 @@ class Poller { continue; Master::Summon(['Onepoll', $contact['abook_id']]); - if ($interval) - @time_sleep_until(microtime(true) + (float)$interval); + if ($interval) { + usleep($interval); + } } } @@ -181,9 +197,12 @@ class Poller { if ($rr['ud_last'] > NULL_DATE) if ($rr['ud_last'] > datetime_convert('UTC', 'UTC', 'now - 1 day')) continue; + Master::Summon(['Onedirsync', $rr['ud_id']]); - if ($interval) - @time_sleep_until(microtime(true) + (float)$interval); + + if ($interval) { + usleep($interval); + } } } } @@ -191,9 +210,9 @@ class Poller { set_config('system', 'lastpoll', datetime_convert()); //All done - clear the lockfile - +/* @unlink($lockfile); - +*/ return; } } diff --git a/Zotlabs/Daemon/Queue.php b/Zotlabs/Daemon/Queue.php index 41aaf45ed..3eb7d9d23 100644 --- a/Zotlabs/Daemon/Queue.php +++ b/Zotlabs/Daemon/Queue.php @@ -79,5 +79,7 @@ class Queue { foreach ($r as $rv) { LibQueue::deliver($rv); } + + return; } } diff --git a/Zotlabs/Daemon/Thumbnail.php b/Zotlabs/Daemon/Thumbnail.php index 3688e8ae5..fa9570658 100644 --- a/Zotlabs/Daemon/Thumbnail.php +++ b/Zotlabs/Daemon/Thumbnail.php @@ -73,5 +73,7 @@ class Thumbnail { || (filectime(dbunescbin($attach['content']) . 'thumb') < (time() - 60)))) { $default_controller->Thumb($attach, $preview_style, $preview_width, $preview_height); } + + return; } } |