Skip to content

Commit 90ec21f

Browse files
author
epriestley
committedFeb 28, 2017
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
1 parent 54059b0 commit 90ec21f

File tree

3 files changed

+31
-3
lines changed

3 files changed

+31
-3
lines changed
 

‎src/applications/daemon/management/PhabricatorDaemonManagementDebugWorkflow.php

+7
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ protected function didConstruct() {
2121
'name' => 'argv',
2222
'wildcard' => true,
2323
),
24+
array(
25+
'name' => 'pool',
26+
'param' => 'count',
27+
'help' => pht('Maximum pool size.'),
28+
'default' => 1,
29+
),
2430
array(
2531
'name' => 'as-current-user',
2632
'help' => pht(
@@ -43,6 +49,7 @@ public function execute(PhutilArgumentParser $args) {
4349
$config = array(
4450
'class' => array_shift($argv),
4551
'label' => 'debug',
52+
'pool' => (int)$args->getArg('pool'),
4653
'argv' => $argv,
4754
);
4855

‎src/infrastructure/daemon/workers/__tests__/PhabricatorTestWorker.php

+8-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,14 @@ public function getWaitBeforeRetry(PhabricatorWorkerTask $task) {
2424
}
2525

2626
protected function doWork() {
27-
switch (idx($this->getTaskData(), 'doWork')) {
27+
$data = $this->getTaskData();
28+
29+
$duration = idx($data, 'duration');
30+
if ($duration) {
31+
usleep($duration * 1000000);
32+
}
33+
34+
switch (idx($data, 'doWork')) {
2835
case 'fail-temporary':
2936
throw new Exception(pht('Temporary failure!'));
3037
case 'fail-permanent':

‎src/infrastructure/daemon/workers/management/PhabricatorWorkerManagementFloodWorkflow.php

+16-2
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,24 @@ protected function didConstruct() {
1111
pht(
1212
'Flood the queue with test tasks. This command is intended for '.
1313
'use when developing and debugging Phabricator.'))
14-
->setArguments(array());
14+
->setArguments(
15+
array(
16+
array(
17+
'name' => 'duration',
18+
'param' => 'seconds',
19+
'help' => pht(
20+
'Queue tasks which require a specific amount of wall time to '.
21+
'complete. By default, tasks complete as quickly as possible.'),
22+
'default' => 0,
23+
),
24+
));
1525
}
1626

1727
public function execute(PhutilArgumentParser $args) {
1828
$console = PhutilConsole::getConsole();
1929

30+
$duration = (float)$args->getArg('duration');
31+
2032
$console->writeOut(
2133
"%s\n",
2234
pht('Adding many test tasks to worker queue. Use ^C to exit.'));
@@ -25,7 +37,9 @@ public function execute(PhutilArgumentParser $args) {
2537
while (true) {
2638
PhabricatorWorker::scheduleTask(
2739
'PhabricatorTestWorker',
28-
array());
40+
array(
41+
'duration' => $duration,
42+
));
2943

3044
if (($n++ % 100) === 0) {
3145
$console->writeOut('.');

0 commit comments

Comments
 (0)
Failed to load comments.