mirror of
https://we.phorge.it/source/phorge.git
synced 2025-02-01 01:18:22 +01:00
Add a "--gently" flag to phd stop
and phd restart
Summary: In the cluster, the box has a ton of stuff that "looks like a daemon" beacuse it is some other instance's daemon. Stop `phd restart` from complaining about this if given a "--gently" flag, which is like the opposite of "--force". (I'll make it `stop --force` at the beginning of a whole-box restart to kill stragglers.) Test Plan: Ran `bin/phd restart --gently`, etc. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Differential Revision: https://secure.phabricator.com/D11784
This commit is contained in:
parent
267ff7fbc9
commit
e946e7cebc
3 changed files with 43 additions and 11 deletions
|
@ -19,6 +19,12 @@ final class PhabricatorDaemonManagementRestartWorkflow
|
|||
'seconds. Defaults to __15__ seconds.'),
|
||||
'default' => 15,
|
||||
),
|
||||
array(
|
||||
'name' => 'gently',
|
||||
'help' => pht(
|
||||
'Ignore running processes that look like daemons but do not '.
|
||||
'have corresponding PID files.'),
|
||||
),
|
||||
array(
|
||||
'name' => 'force',
|
||||
'help' => pht(
|
||||
|
@ -29,12 +35,17 @@ final class PhabricatorDaemonManagementRestartWorkflow
|
|||
}
|
||||
|
||||
public function execute(PhutilArgumentParser $args) {
|
||||
$graceful = $args->getArg('graceful');
|
||||
$force = $args->getArg('force');
|
||||
$err = $this->executeStopCommand(array(), $graceful, $force);
|
||||
$err = $this->executeStopCommand(
|
||||
array(),
|
||||
array(
|
||||
'graceful' => $args->getArg('graceful'),
|
||||
'force' => $args->getArg('force'),
|
||||
'gently' => $args->getArg('gently'),
|
||||
));
|
||||
if ($err) {
|
||||
return $err;
|
||||
}
|
||||
|
||||
return $this->executeStartCommand();
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,12 @@ final class PhabricatorDaemonManagementStopWorkflow
|
|||
'Also stop running processes that look like daemons but do '.
|
||||
'not have corresponding PID files.'),
|
||||
),
|
||||
array(
|
||||
'name' => 'gently',
|
||||
'help' => pht(
|
||||
'Ignore running processes that look like daemons but do not '.
|
||||
'have corresponding PID files.'),
|
||||
),
|
||||
array(
|
||||
'name' => 'pids',
|
||||
'wildcard' => true,
|
||||
|
@ -34,10 +40,13 @@ final class PhabricatorDaemonManagementStopWorkflow
|
|||
}
|
||||
|
||||
public function execute(PhutilArgumentParser $args) {
|
||||
$pids = $args->getArg('pids');
|
||||
$graceful = $args->getArg('graceful');
|
||||
$force = $args->getArg('force');
|
||||
return $this->executeStopCommand($pids, $graceful, $force);
|
||||
return $this->executeStopCommand(
|
||||
$args->getArg('pids'),
|
||||
array(
|
||||
'graceful' => $args->getArg('graceful'),
|
||||
'force' => $args->getArg('force'),
|
||||
'gently' => $args->getArg('gently'),
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -361,15 +361,25 @@ abstract class PhabricatorDaemonManagementWorkflow
|
|||
|
||||
protected final function executeStopCommand(
|
||||
array $pids,
|
||||
$grace_period,
|
||||
$force) {
|
||||
array $options) {
|
||||
|
||||
$console = PhutilConsole::getConsole();
|
||||
|
||||
$grace_period = idx($options, 'graceful', 15);
|
||||
$force = idx($options, 'force');
|
||||
$gently = idx($options, 'gently');
|
||||
|
||||
if ($gently && $force) {
|
||||
throw new PhutilArgumentUsageException(
|
||||
pht(
|
||||
'You can not specify conflicting options --gently and --force '.
|
||||
'together.'));
|
||||
}
|
||||
|
||||
$daemons = $this->loadRunningDaemons();
|
||||
if (!$daemons) {
|
||||
$survivors = array();
|
||||
if (!$pids) {
|
||||
if (!$pids && !$gently) {
|
||||
$survivors = $this->processRogueDaemons(
|
||||
$grace_period,
|
||||
$warn = true,
|
||||
|
@ -421,7 +431,9 @@ abstract class PhabricatorDaemonManagementWorkflow
|
|||
}
|
||||
}
|
||||
|
||||
$this->processRogueDaemons($grace_period, !$pids, $force);
|
||||
if (!$gently) {
|
||||
$this->processRogueDaemons($grace_period, !$pids, $force);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue