Page MenuHomePhabricator

D9256.diff
No OneTemporary

D9256.diff

diff --git a/src/applications/daemon/management/PhabricatorDaemonManagementStartWorkflow.php b/src/applications/daemon/management/PhabricatorDaemonManagementStartWorkflow.php
--- a/src/applications/daemon/management/PhabricatorDaemonManagementStartWorkflow.php
+++ b/src/applications/daemon/management/PhabricatorDaemonManagementStartWorkflow.php
@@ -11,11 +11,19 @@
'Start the standard configured collection of Phabricator daemons. '.
'This is appropriate for most installs. Use **phd launch** to '.
'customize which daemons are launched.'))
- ->setArguments(array());
+ ->setArguments(
+ array(
+ array(
+ 'name' => 'keep-leases',
+ 'help' => pht(
+ 'By default, **phd start** will free all task leases held by '.
+ 'the daemons. With this flag, this step will be skipped.'),
+ ),
+ ));
}
public function execute(PhutilArgumentParser $args) {
- return $this->executeStartCommand();
+ return $this->executeStartCommand($args->getArg('keep-leases'));
}
}
diff --git a/src/applications/daemon/management/PhabricatorDaemonManagementWorkflow.php b/src/applications/daemon/management/PhabricatorDaemonManagementWorkflow.php
--- a/src/applications/daemon/management/PhabricatorDaemonManagementWorkflow.php
+++ b/src/applications/daemon/management/PhabricatorDaemonManagementWorkflow.php
@@ -224,7 +224,7 @@
/* -( Commands )----------------------------------------------------------- */
- protected function executeStartCommand() {
+ protected function executeStartCommand($keep_leases = false) {
$console = PhutilConsole::getConsole();
$running = $this->loadRunningDaemons();
@@ -246,6 +246,16 @@
}
}
+ if ($keep_leases) {
+ $console->writeErr("%s\n", pht('Not touching active task queue leases.'));
+ } else {
+ $console->writeErr("%s\n", pht('Freeing active task leases...'));
+ $count = $this->freeActiveLeases();
+ $console->writeErr(
+ "%s\n",
+ pht('Freed %s task lease(s).', new PhutilNumber($count)));
+ }
+
$daemons = array(
array('PhabricatorRepositoryPullLocalDaemon', array()),
array('PhabricatorGarbageCollectorDaemon', array()),
@@ -352,4 +362,15 @@
return 0;
}
+ private function freeActiveLeases() {
+ $task_table = id(new PhabricatorWorkerActiveTask());
+ $conn_w = $task_table->establishConnection('w');
+ queryfx(
+ $conn_w,
+ 'UPDATE %T SET leaseExpires = UNIX_TIMESTAMP()
+ WHERE leaseExpires > UNIX_TIMESTAMP()',
+ $task_table->getTableName());
+ return $conn_w->getAffectedRows();
+ }
+
}

File Metadata

Mime Type
text/plain
Expires
Mon, May 13, 11:22 PM (2 w, 4 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6274031
Default Alt Text
D9256.diff (2 KB)

Event Timeline