Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14077169
D20246.id48319.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
D20246.id48319.diff
View Options
diff --git a/src/infrastructure/daemon/workers/management/PhabricatorWorkerManagementExecuteWorkflow.php b/src/infrastructure/daemon/workers/management/PhabricatorWorkerManagementExecuteWorkflow.php
--- a/src/infrastructure/daemon/workers/management/PhabricatorWorkerManagementExecuteWorkflow.php
+++ b/src/infrastructure/daemon/workers/management/PhabricatorWorkerManagementExecuteWorkflow.php
@@ -11,23 +11,64 @@
pht(
'Execute a task explicitly. This command ignores leases, is '.
'dangerous, and may cause work to be performed twice.'))
- ->setArguments($this->getTaskSelectionArguments());
+ ->setArguments(
+ array_merge(
+ array(
+ array(
+ 'name' => 'retry',
+ 'help' => pht('Retry archived tasks.'),
+ ),
+ array(
+ 'name' => 'repeat',
+ 'help' => pht('Repeat archived, successful tasks.'),
+ ),
+ ),
+ $this->getTaskSelectionArguments()));
}
public function execute(PhutilArgumentParser $args) {
$console = PhutilConsole::getConsole();
$tasks = $this->loadTasks($args);
+ $is_retry = $args->getArg('retry');
+ $is_repeat = $args->getArg('repeat');
+
foreach ($tasks as $task) {
$can_execute = !$task->isArchived();
if (!$can_execute) {
- $console->writeOut(
+ if (!$is_retry) {
+ $console->writeOut(
+ "**<bg:yellow> %s </bg>** %s\n",
+ pht('ARCHIVED'),
+ pht(
+ '%s is already archived, and will not be executed. '.
+ 'Use "--retry" to execute archived tasks.',
+ $this->describeTask($task)));
+ continue;
+ }
+
+ $result_success = PhabricatorWorkerArchiveTask::RESULT_SUCCESS;
+ if ($task->getResult() == $result_success) {
+ if (!$is_repeat) {
+ $console->writeOut(
+ "**<bg:yellow> %s </bg>** %s\n",
+ pht('SUCCEEDED'),
+ pht(
+ '%s has already succeeded, and will not be retried. '.
+ 'Use "--repeat" to repeat successful tasks.',
+ $this->describeTask($task)));
+ continue;
+ }
+ }
+
+ echo tsprintf(
"**<bg:yellow> %s </bg>** %s\n",
pht('ARCHIVED'),
pht(
- '%s is already archived, and can not be executed.',
+ 'Unarchiving %s.',
$this->describeTask($task)));
- continue;
+
+ $task = $task->unarchiveTask();
}
// NOTE: This ignores leases, maybe it should respect them without
diff --git a/src/infrastructure/daemon/workers/management/PhabricatorWorkerManagementRetryWorkflow.php b/src/infrastructure/daemon/workers/management/PhabricatorWorkerManagementRetryWorkflow.php
--- a/src/infrastructure/daemon/workers/management/PhabricatorWorkerManagementRetryWorkflow.php
+++ b/src/infrastructure/daemon/workers/management/PhabricatorWorkerManagementRetryWorkflow.php
@@ -10,15 +10,24 @@
->setSynopsis(
pht(
'Retry selected tasks which previously failed permanently or '.
- 'were cancelled. Only archived, unsuccessful tasks can be '.
- 'retried.'))
- ->setArguments($this->getTaskSelectionArguments());
+ 'were cancelled. Only archived tasks can be retried.'))
+ ->setArguments(
+ array_merge(
+ array(
+ array(
+ 'name' => 'repeat',
+ 'help' => pht(
+ 'Repeat tasks which already completed successfully.'),
+ ),
+ ),
+ $this->getTaskSelectionArguments()));
}
public function execute(PhutilArgumentParser $args) {
$console = PhutilConsole::getConsole();
$tasks = $this->loadTasks($args);
+ $is_repeat = $args->getArg('repeat');
foreach ($tasks as $task) {
if (!$task->isArchived()) {
$console->writeOut(
@@ -32,13 +41,16 @@
$result_success = PhabricatorWorkerArchiveTask::RESULT_SUCCESS;
if ($task->getResult() == $result_success) {
- $console->writeOut(
- "**<bg:yellow> %s </bg>** %s\n",
- pht('SUCCEEDED'),
- pht(
- '%s has already succeeded, and can not be retried.',
- $this->describeTask($task)));
- continue;
+ if (!$is_repeat) {
+ $console->writeOut(
+ "**<bg:yellow> %s </bg>** %s\n",
+ pht('SUCCEEDED'),
+ pht(
+ '%s has already succeeded, and will not be repeated. '.
+ 'Use "--repeat" to repeat successful tasks.',
+ $this->describeTask($task)));
+ continue;
+ }
}
$task->unarchiveTask();
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Nov 22, 9:49 PM (14 h, 13 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6776065
Default Alt Text
D20246.id48319.diff (4 KB)
Attached To
Mode
D20246: Give "bin/worker" flags to repeat and retry tasks
Attached
Detach File
Event Timeline
Log In to Comment