Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15459463
D9256.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D9256.id.diff
View Options
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
Details
Attached
Mime Type
text/plain
Expires
Tue, Apr 1, 1:08 PM (2 w, 1 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7704562
Default Alt Text
D9256.id.diff (2 KB)
Attached To
Mode
D9256: Free task leases on "phd start"
Attached
Detach File
Event Timeline
Log In to Comment