Page MenuHomestyx hydra

No OneTemporary

diff --git a/src/applications/daemon/management/PhabricatorDaemonManagementDebugWorkflow.php b/src/applications/daemon/management/PhabricatorDaemonManagementDebugWorkflow.php
index 9a535af617..e861d238f2 100644
--- a/src/applications/daemon/management/PhabricatorDaemonManagementDebugWorkflow.php
+++ b/src/applications/daemon/management/PhabricatorDaemonManagementDebugWorkflow.php
@@ -1,57 +1,64 @@
<?php
final class PhabricatorDaemonManagementDebugWorkflow
extends PhabricatorDaemonManagementWorkflow {
public function shouldParsePartial() {
return true;
}
protected function didConstruct() {
$this
->setName('debug')
->setExamples('**debug** __daemon__')
->setSynopsis(
pht(
'Start __daemon__ in the foreground and print large volumes of '.
'diagnostic information to the console.'))
->setArguments(
array(
array(
'name' => 'argv',
'wildcard' => true,
),
+ array(
+ 'name' => 'pool',
+ 'param' => 'count',
+ 'help' => pht('Maximum pool size.'),
+ 'default' => 1,
+ ),
array(
'name' => 'as-current-user',
'help' => pht(
'Run the daemon as the current user '.
'instead of the configured %s',
'phd.user'),
),
));
}
public function execute(PhutilArgumentParser $args) {
$argv = $args->getArg('argv');
$run_as_current_user = $args->getArg('as-current-user');
if (!$argv) {
throw new PhutilArgumentUsageException(
pht('You must specify which daemon to debug.'));
}
$config = array(
'class' => array_shift($argv),
'label' => 'debug',
+ 'pool' => (int)$args->getArg('pool'),
'argv' => $argv,
);
return $this->launchDaemons(
array(
$config,
),
$is_debug = true,
$run_as_current_user);
}
}
diff --git a/src/infrastructure/daemon/workers/__tests__/PhabricatorTestWorker.php b/src/infrastructure/daemon/workers/__tests__/PhabricatorTestWorker.php
index 86e83acb82..f899ec1775 100644
--- a/src/infrastructure/daemon/workers/__tests__/PhabricatorTestWorker.php
+++ b/src/infrastructure/daemon/workers/__tests__/PhabricatorTestWorker.php
@@ -1,38 +1,45 @@
<?php
final class PhabricatorTestWorker extends PhabricatorWorker {
public function getRequiredLeaseTime() {
return idx(
$this->getTaskData(),
'getRequiredLeaseTime',
parent::getRequiredLeaseTime());
}
public function getMaximumRetryCount() {
return idx(
$this->getTaskData(),
'getMaximumRetryCount',
parent::getMaximumRetryCount());
}
public function getWaitBeforeRetry(PhabricatorWorkerTask $task) {
return idx(
$this->getTaskData(),
'getWaitBeforeRetry',
parent::getWaitBeforeRetry($task));
}
protected function doWork() {
- switch (idx($this->getTaskData(), 'doWork')) {
+ $data = $this->getTaskData();
+
+ $duration = idx($data, 'duration');
+ if ($duration) {
+ usleep($duration * 1000000);
+ }
+
+ switch (idx($data, 'doWork')) {
case 'fail-temporary':
throw new Exception(pht('Temporary failure!'));
case 'fail-permanent':
throw new PhabricatorWorkerPermanentFailureException(
pht('Permanent failure!'));
default:
return;
}
}
}
diff --git a/src/infrastructure/daemon/workers/management/PhabricatorWorkerManagementFloodWorkflow.php b/src/infrastructure/daemon/workers/management/PhabricatorWorkerManagementFloodWorkflow.php
index 9bf52cfb71..fb067ddaac 100644
--- a/src/infrastructure/daemon/workers/management/PhabricatorWorkerManagementFloodWorkflow.php
+++ b/src/infrastructure/daemon/workers/management/PhabricatorWorkerManagementFloodWorkflow.php
@@ -1,36 +1,50 @@
<?php
final class PhabricatorWorkerManagementFloodWorkflow
extends PhabricatorWorkerManagementWorkflow {
protected 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());
+ ->setArguments(
+ array(
+ array(
+ 'name' => 'duration',
+ 'param' => 'seconds',
+ 'help' => pht(
+ 'Queue tasks which require a specific amount of wall time to '.
+ 'complete. By default, tasks complete as quickly as possible.'),
+ 'default' => 0,
+ ),
+ ));
}
public function execute(PhutilArgumentParser $args) {
$console = PhutilConsole::getConsole();
+ $duration = (float)$args->getArg('duration');
+
$console->writeOut(
"%s\n",
pht('Adding many test tasks to worker queue. Use ^C to exit.'));
$n = 0;
while (true) {
PhabricatorWorker::scheduleTask(
'PhabricatorTestWorker',
- array());
+ array(
+ 'duration' => $duration,
+ ));
if (($n++ % 100) === 0) {
$console->writeOut('.');
}
}
}
}

File Metadata

Mime Type
text/x-diff
Expires
Mon, Jul 28, 6:24 PM (1 w, 3 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
187287
Default Alt Text
(5 KB)

Event Timeline