Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13984095
D10894.id26177.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
D10894.id26177.diff
View Options
diff --git a/bin/worker b/bin/worker
new file mode 120000
--- /dev/null
+++ b/bin/worker
@@ -0,0 +1 @@
+../scripts/setup/manage_worker.php
\ No newline at end of file
diff --git a/scripts/setup/manage_worker.php b/scripts/setup/manage_worker.php
new file mode 100755
--- /dev/null
+++ b/scripts/setup/manage_worker.php
@@ -0,0 +1,21 @@
+#!/usr/bin/env php
+<?php
+
+$root = dirname(dirname(dirname(__FILE__)));
+require_once $root.'/scripts/__init_script__.php';
+
+$args = new PhutilArgumentParser($argv);
+$args->setTagline('manage task queue');
+$args->setSynopsis(<<<EOSYNOPSIS
+**worker** __command__ [__options__]
+ Manage the task queue.
+
+EOSYNOPSIS
+ );
+$args->parseStandardArguments();
+
+$workflows = id(new PhutilSymbolLoader())
+ ->setAncestorClass('PhabricatorWorkerManagementWorkflow')
+ ->loadObjects();
+$workflows[] = new PhutilHelpArgumentWorkflow();
+$args->parseWorkflows($workflows);
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -2515,6 +2515,8 @@
'PhabricatorWorkerArchiveTask' => 'infrastructure/daemon/workers/storage/PhabricatorWorkerArchiveTask.php',
'PhabricatorWorkerDAO' => 'infrastructure/daemon/workers/storage/PhabricatorWorkerDAO.php',
'PhabricatorWorkerLeaseQuery' => 'infrastructure/daemon/workers/query/PhabricatorWorkerLeaseQuery.php',
+ 'PhabricatorWorkerManagementFloodWorkflow' => 'infrastructure/daemon/workers/management/PhabricatorWorkerManagementFloodWorkflow.php',
+ 'PhabricatorWorkerManagementWorkflow' => 'infrastructure/daemon/workers/management/PhabricatorWorkerManagementWorkflow.php',
'PhabricatorWorkerPermanentFailureException' => 'infrastructure/daemon/workers/exception/PhabricatorWorkerPermanentFailureException.php',
'PhabricatorWorkerTask' => 'infrastructure/daemon/workers/storage/PhabricatorWorkerTask.php',
'PhabricatorWorkerTaskData' => 'infrastructure/daemon/workers/storage/PhabricatorWorkerTaskData.php',
@@ -5676,6 +5678,8 @@
'PhabricatorWorkerArchiveTask' => 'PhabricatorWorkerTask',
'PhabricatorWorkerDAO' => 'PhabricatorLiskDAO',
'PhabricatorWorkerLeaseQuery' => 'PhabricatorQuery',
+ 'PhabricatorWorkerManagementFloodWorkflow' => 'PhabricatorWorkerManagementWorkflow',
+ 'PhabricatorWorkerManagementWorkflow' => 'PhabricatorManagementWorkflow',
'PhabricatorWorkerPermanentFailureException' => 'Exception',
'PhabricatorWorkerTask' => 'PhabricatorWorkerDAO',
'PhabricatorWorkerTaskData' => 'PhabricatorWorkerDAO',
diff --git a/src/infrastructure/daemon/workers/management/PhabricatorWorkerManagementFloodWorkflow.php b/src/infrastructure/daemon/workers/management/PhabricatorWorkerManagementFloodWorkflow.php
new file mode 100644
--- /dev/null
+++ b/src/infrastructure/daemon/workers/management/PhabricatorWorkerManagementFloodWorkflow.php
@@ -0,0 +1,36 @@
+<?php
+
+final class PhabricatorWorkerManagementFloodWorkflow
+ extends PhabricatorWorkerManagementWorkflow {
+
+ public function didConstruct() {
+ $this
+ ->setName('flood')
+ ->setExamples('**flood**')
+ ->setSynopsis(
+ pht(
+ 'Flood the queue with test tasks. This command is intended for '.
+ 'use when developing and debugging Phabricator.'))
+ ->setArguments(array());
+ }
+
+ public function execute(PhutilArgumentParser $args) {
+ $console = PhutilConsole::getConsole();
+
+ $console->writeOut(
+ "%s\n",
+ pht('Adding many test tasks to worker queue. Use ^C to exit.'));
+
+ $n = 0;
+ while (true) {
+ PhabricatorWorker::scheduleTask(
+ 'PhabricatorTestWorker',
+ array());
+
+ if (($n++ % 100) === 0) {
+ $console->writeOut('.');
+ }
+ }
+ }
+
+}
diff --git a/src/infrastructure/daemon/workers/management/PhabricatorWorkerManagementWorkflow.php b/src/infrastructure/daemon/workers/management/PhabricatorWorkerManagementWorkflow.php
new file mode 100644
--- /dev/null
+++ b/src/infrastructure/daemon/workers/management/PhabricatorWorkerManagementWorkflow.php
@@ -0,0 +1,4 @@
+<?php
+
+abstract class PhabricatorWorkerManagementWorkflow
+ extends PhabricatorManagementWorkflow {}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Oct 21, 10:59 AM (4 w, 4 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6714805
Default Alt Text
D10894.id26177.diff (4 KB)
Attached To
Mode
D10894: Add `bin/worker flood`, for flooding the task queue with work
Attached
Detach File
Event Timeline
Log In to Comment