aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Module
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2022-12-02 19:22:19 +0000
committerMario <mario@mariovavti.com>2022-12-02 19:22:19 +0000
commit2bb58843ab303ba3e1a4a2c0c5a64138852ebbe0 (patch)
tree1e85f560122aae0b30dfe5a55c3de90fbce64ed1 /Zotlabs/Module
parentd16b6c3838cd76eb7ce336444cbd37774857b64f (diff)
downloadvolse-hubzilla-2bb58843ab303ba3e1a4a2c0c5a64138852ebbe0.tar.gz
volse-hubzilla-2bb58843ab303ba3e1a4a2c0c5a64138852ebbe0.tar.bz2
volse-hubzilla-2bb58843ab303ba3e1a4a2c0c5a64138852ebbe0.zip
move queueworker to core and bump version
Diffstat (limited to 'Zotlabs/Module')
-rw-r--r--Zotlabs/Module/Import.php2
-rw-r--r--Zotlabs/Module/Queueworker.php122
2 files changed, 123 insertions, 1 deletions
diff --git a/Zotlabs/Module/Import.php b/Zotlabs/Module/Import.php
index ec47e370b..c8a9ac5ed 100644
--- a/Zotlabs/Module/Import.php
+++ b/Zotlabs/Module/Import.php
@@ -536,7 +536,7 @@ class Import extends Controller {
$since = datetime_convert(date_default_timezone_get(), date_default_timezone_get(), '0001-01-01 00:00');
$until = datetime_convert(date_default_timezone_get(), date_default_timezone_get(), 'now + 1 day');
- $poll_interval = get_config('system', 'poll_interval', 3);
+ //$poll_interval = get_config('system', 'poll_interval', 3);
$page = 0;
Master::Summon(['Content_importer', sprintf('%d', $page), $since, $until, $channel['channel_address'], urlencode($hz_server)]);
diff --git a/Zotlabs/Module/Queueworker.php b/Zotlabs/Module/Queueworker.php
new file mode 100644
index 000000000..808a9ed61
--- /dev/null
+++ b/Zotlabs/Module/Queueworker.php
@@ -0,0 +1,122 @@
+<?php
+
+namespace Zotlabs\Module;
+
+use App;
+use Zotlabs\Web\Controller;
+
+class Queueworker extends Controller {
+
+ function init() {
+
+ }
+
+ function post() {
+
+ if ((!local_channel()) || (!is_site_admin())) {
+ goaway(z_root() . '/queueworker');
+ }
+
+ check_form_security_token('form_security_token', 'queueworker');
+
+ $maxqueueworkers = intval($_POST['queueworker_maxworkers']);
+ $maxqueueworkers = ($maxqueueworkers > 3) ? $maxqueueworkers : 4;
+ set_config('queueworker', 'max_queueworkers', $maxqueueworkers);
+
+ $maxworkerage = intval($_POST['queueworker_max_age']);
+ $maxworkerage = ($maxworkerage >= 120) ? $maxworkerage : 300;
+ set_config('queueworker', 'queueworker_max_age', $maxworkerage);
+
+ $queueworkersleep = intval($_POST['queue_worker_sleep']);
+ $queueworkersleep = ($queueworkersleep > 100) ? $queueworkersleep : 100;
+ set_config('queueworker', 'queue_worker_sleep', $queueworkersleep);
+
+ goaway(z_root() . '/queueworker');
+ }
+
+ function get() {
+
+ $content = "<H1>ERROR: Page not found</H1>";
+ App::$error = 404;
+
+ if (!local_channel()) {
+ return $content;
+ }
+
+ if (!(is_site_admin())) {
+ return $content;
+ }
+
+ load_config("queueworker");
+
+ $content = "<H1>Queue Status</H1>\n";
+
+ $r = q('select count(*) as qentries from workerq');
+
+ if (!$r) {
+ $content = "<H4>There was an error querying the database.</H4>";
+ return $content;
+ }
+
+ $content .= "<H4>There are " . $r[0]['qentries'] . " queue items to be processed.</H4>";
+
+ $r = dbq("select count(distinct workerq_reservationid) as qworkers from workerq where workerq_reservationid is not null");
+
+ $content .= "<H4>Active workers: " . $r[0]['qworkers'] . "</H4>";
+
+ $maxqueueworkers = get_config('queueworker', 'max_queueworkers', 4);
+ $maxqueueworkers = ($maxqueueworkers > 3) ? $maxqueueworkers : 4;
+ set_config('queueworker', 'max_queueworkers', $maxqueueworkers);
+
+ $sc = '';
+
+ $sc .= replace_macros(get_markup_template('field_input.tpl'), [
+ '$field' => [
+ 'queueworker_maxworkers',
+ t('Max queueworker threads'),
+ $maxqueueworkers,
+ t('Minimum 4, default 4')
+ ]
+ ]);
+
+ $workermaxage = get_config('queueworker', 'queueworker_max_age');
+ $workermaxage = ($workermaxage >= 120) ? $workermaxage : 300;
+ set_config('queueworker', 'max_queueworker_age', $workermaxage);
+
+ $sc .= replace_macros(get_markup_template('field_input.tpl'), [
+ '$field' => [
+ 'queueworker_max_age',
+ t('Assume workers dead after'),
+ $workermaxage,
+ t('Minimum 120, default 300 seconds')
+ ]
+ ]);
+
+ $queueworkersleep = get_config('queueworker', 'queue_worker_sleep');
+ $queueworkersleep = ($queueworkersleep > 100) ? $queueworkersleep : 100;
+ set_config('queueworker', 'queue_worker_sleep', $queueworkersleep);
+
+ $sc .= replace_macros(get_markup_template('field_input.tpl'), [
+ '$field' => [
+ 'queue_worker_sleep',
+ t('Pause before starting next task'),
+ $queueworkersleep,
+ t('Minimum 100, default 100 microseconds')
+ ]
+ ]);
+
+ $tpl = get_markup_template('settings_addon.tpl');
+ $content .= replace_macros($tpl, [
+ '$action_url' => 'queueworker',
+ '$form_security_token' => get_form_security_token('queueworker'),
+ '$title' => t('Queueworker Settings'),
+ '$content' => $sc,
+ '$baseurl' => z_root(),
+ '$submit' => t('Save')
+ ]
+ );
+
+ return $content;
+
+ }
+}