mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-20 12:30:56 +01:00
Add a --force command to phd start
Summary: Ref T7352. This isn't wildly useful for us but seems generally reasonable, can be helpful with testing, and @hach-que has a use case for it. The only reason we issue this warning is to prevent user error; you can still launch all the daemons with `phd launch` manually and daemons all use locks to protect critical regions. Test Plan: Ran `phd start --force` a bunch, saw zillions of daemons. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley, hach-que Maniphest Tasks: T7352 Differential Revision: https://secure.phabricator.com/D11861
This commit is contained in:
parent
48fc3126a1
commit
ef22fe1e74
2 changed files with 26 additions and 16 deletions
|
@ -19,11 +19,18 @@ final class PhabricatorDaemonManagementStartWorkflow
|
|||
'By default, **phd start** will free all task leases held by '.
|
||||
'the daemons. With this flag, this step will be skipped.'),
|
||||
),
|
||||
array(
|
||||
'name' => 'force',
|
||||
'help' => pht(
|
||||
'Start daemons even if daemons are already running.'),
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
public function execute(PhutilArgumentParser $args) {
|
||||
return $this->executeStartCommand($args->getArg('keep-leases'));
|
||||
return $this->executeStartCommand(
|
||||
$args->getArg('keep-leases'),
|
||||
$args->getArg('force'));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -286,25 +286,28 @@ abstract class PhabricatorDaemonManagementWorkflow
|
|||
/* -( Commands )----------------------------------------------------------- */
|
||||
|
||||
|
||||
protected final function executeStartCommand($keep_leases = false) {
|
||||
protected final function executeStartCommand($keep_leases, $force) {
|
||||
$console = PhutilConsole::getConsole();
|
||||
|
||||
$running = $this->loadRunningDaemons();
|
||||
if (!$force) {
|
||||
$running = $this->loadRunningDaemons();
|
||||
|
||||
// This may include daemons which were launched but which are no longer
|
||||
// running; check that we actually have active daemons before failing.
|
||||
foreach ($running as $daemon) {
|
||||
if ($daemon->isRunning()) {
|
||||
$message = pht(
|
||||
"phd start: Unable to start daemons because daemons are already ".
|
||||
"running.\n".
|
||||
"You can view running daemons with 'phd status'.\n".
|
||||
"You can stop running daemons with 'phd stop'.\n".
|
||||
"You can use 'phd restart' to stop all daemons before starting new ".
|
||||
"daemons.");
|
||||
// This may include daemons which were launched but which are no longer
|
||||
// running; check that we actually have active daemons before failing.
|
||||
foreach ($running as $daemon) {
|
||||
if ($daemon->isRunning()) {
|
||||
$message = pht(
|
||||
"phd start: Unable to start daemons because daemons are already ".
|
||||
"running.\n\n".
|
||||
"You can view running daemons with 'phd status'.\n".
|
||||
"You can stop running daemons with 'phd stop'.\n".
|
||||
"You can use 'phd restart' to stop all daemons before starting ".
|
||||
"new daemons.\n".
|
||||
"You can force daemons to start anyway with --force.");
|
||||
|
||||
$console->writeErr("%s\n", $message);
|
||||
exit(1);
|
||||
$console->writeErr("%s\n", $message);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue