1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-09-20 09:18:48 +02:00

Add "--pool" and "--duration" flags to daemon CLI tools

Summary: Ref T12331. These changes are intended to make it easier to debug T12331 since I'm having difficulty reproducing the issue locally.

Test Plan:
  - Ran `bin/phd debug task --pool 4` and got an autoscaling pool.
  - Ran `bin/worker flood --duration 3` and got some 3-second-long tasks to execute with `bin/worker execute ...`.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T12331

Differential Revision: https://secure.phabricator.com/D17431
This commit is contained in:
epriestley 2017-02-28 07:13:35 -08:00
parent 54059b0a9d
commit 90ec21f999
3 changed files with 31 additions and 3 deletions

View file

@ -21,6 +21,12 @@ final class PhabricatorDaemonManagementDebugWorkflow
'name' => 'argv',
'wildcard' => true,
),
array(
'name' => 'pool',
'param' => 'count',
'help' => pht('Maximum pool size.'),
'default' => 1,
),
array(
'name' => 'as-current-user',
'help' => pht(
@ -43,6 +49,7 @@ final class PhabricatorDaemonManagementDebugWorkflow
$config = array(
'class' => array_shift($argv),
'label' => 'debug',
'pool' => (int)$args->getArg('pool'),
'argv' => $argv,
);

View file

@ -24,7 +24,14 @@ final class PhabricatorTestWorker extends PhabricatorWorker {
}
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':

View file

@ -11,12 +11,24 @@ final class PhabricatorWorkerManagementFloodWorkflow
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.'));
@ -25,7 +37,9 @@ final class PhabricatorWorkerManagementFloodWorkflow
while (true) {
PhabricatorWorker::scheduleTask(
'PhabricatorTestWorker',
array());
array(
'duration' => $duration,
));
if (($n++ % 100) === 0) {
$console->writeOut('.');