1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 06:42:42 +01:00

Support an "--active" flag for selecting active tasks

Summary: Ref T13591. This is mostly a workaround for Big Sur not having pcntl/posix installed by default and the mess with M1 / Homebrew / SIP / Code Signing (see T13232) so I can't easily run actual daemons and need to fake them with `bin/worker execute --active`, but it's a reasonable flag on its own.

Test Plan:
  - Ran `bin/worker execute --active` and `bin/worker cancel --active`.

Maniphest Tasks: T13591

Differential Revision: https://secure.phabricator.com/D21517
This commit is contained in:
epriestley 2021-01-22 16:08:42 -08:00
parent 3cb543ef8f
commit 15e022d648

View file

@ -21,6 +21,10 @@ abstract class PhabricatorWorkerManagementWorkflow
'param' => 'int',
'help' => pht('Limit to tasks with at least this many failures.'),
),
array(
'name' => 'active',
'help' => pht('Select all active tasks.'),
),
);
}
@ -28,10 +32,13 @@ abstract class PhabricatorWorkerManagementWorkflow
$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();
@ -56,7 +63,13 @@ abstract class PhabricatorWorkerManagementWorkflow
}
$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');