Page MenuHomestyx hydra

No OneTemporary

diff --git a/src/infrastructure/daemon/workers/management/PhabricatorWorkerManagementWorkflow.php b/src/infrastructure/daemon/workers/management/PhabricatorWorkerManagementWorkflow.php
index 2f4ee2f4f5..113f3348d5 100644
--- a/src/infrastructure/daemon/workers/management/PhabricatorWorkerManagementWorkflow.php
+++ b/src/infrastructure/daemon/workers/management/PhabricatorWorkerManagementWorkflow.php
@@ -1,107 +1,120 @@
<?php
abstract class PhabricatorWorkerManagementWorkflow
extends PhabricatorManagementWorkflow {
protected function getTaskSelectionArguments() {
return array(
array(
'name' => 'id',
'param' => 'id',
'repeat' => true,
'help' => pht('Select one or more tasks by ID.'),
),
array(
'name' => 'class',
'param' => 'name',
'help' => pht('Select all tasks of a given class.'),
),
array(
'name' => 'min-failure-count',
'param' => 'int',
'help' => pht('Limit to tasks with at least this many failures.'),
),
+ array(
+ 'name' => 'active',
+ 'help' => pht('Select all active tasks.'),
+ ),
);
}
protected function loadTasks(PhutilArgumentParser $args) {
$ids = $args->getArg('id');
$class = $args->getArg('class');
$min_failures = $args->getArg('min-failure-count');
+ $active = $args->getArg('active');
- if (!$ids && !$class && !$min_failures) {
+ if (!$ids && !$class && !$min_failures && !$active) {
throw new PhutilArgumentUsageException(
- pht('Use --id, --class, or --min-failure-count to select tasks.'));
+ pht(
+ 'Use "--id", "--class", "--active", and/or "--min-failure-count" '.
+ 'to select tasks.'));
}
$active_query = new PhabricatorWorkerActiveTaskQuery();
$archive_query = new PhabricatorWorkerArchiveTaskQuery();
if ($ids) {
$active_query = $active_query->withIDs($ids);
$archive_query = $archive_query->withIDs($ids);
}
if ($class) {
$class_array = array($class);
$active_query = $active_query->withClassNames($class_array);
$archive_query = $archive_query->withClassNames($class_array);
}
if ($min_failures) {
$active_query = $active_query->withFailureCountBetween(
$min_failures, null);
$archive_query = $archive_query->withFailureCountBetween(
$min_failures, null);
}
$active_tasks = $active_query->execute();
- $archive_tasks = $archive_query->execute();
+
+ if ($active) {
+ $archive_tasks = array();
+ } else {
+ $archive_tasks = $archive_query->execute();
+ }
+
$tasks =
mpull($active_tasks, null, 'getID') +
mpull($archive_tasks, null, 'getID');
if ($ids) {
foreach ($ids as $id) {
if (empty($tasks[$id])) {
throw new PhutilArgumentUsageException(
pht('No task exists with id "%s"!', $id));
}
}
}
if ($class && $min_failures) {
if (!$tasks) {
throw new PhutilArgumentUsageException(
pht('No task exists with class "%s" and at least %d failures!',
$class,
$min_failures));
}
} else if ($class) {
if (!$tasks) {
throw new PhutilArgumentUsageException(
pht('No task exists with class "%s"!', $class));
}
} else if ($min_failures) {
if (!$tasks) {
throw new PhutilArgumentUsageException(
pht('No tasks exist with at least %d failures!', $min_failures));
}
}
// When we lock tasks properly, this gets populated as a side effect. Just
// fake it when doing manual CLI stuff. This makes sure CLI yields have
// their expires times set properly.
foreach ($tasks as $task) {
if ($task instanceof PhabricatorWorkerActiveTask) {
$task->setServerTime(PhabricatorTime::getNow());
}
}
return $tasks;
}
protected function describeTask(PhabricatorWorkerTask $task) {
return pht('Task %d (%s)', $task->getID(), $task->getTaskClass());
}
}

File Metadata

Mime Type
text/x-diff
Expires
Sun, Nov 24, 5:03 AM (1 d, 8 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
980
Default Alt Text
(4 KB)

Event Timeline