mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 08:52:39 +01:00
Daemons - better handle rogue daemons from phd
Summary: Ref T2374. While building D10367 I noticed that phd was finding rogue daemons way more than it should be. Re-jigger this code path so rogue daemons are checked for *after* we've dealt with known daemons. This keeps the logic pretty simple overall. Test Plan: phd start; kill pid files; phd stop and get the right warning; phd stop --force and it kills the rogue demons. phd stop in normal conditions no longer reporting rogue daemons erroneously Reviewers: epriestley Reviewed By: epriestley Subscribers: epriestley, Korvin Maniphest Tasks: T2374 Differential Revision: https://secure.phabricator.com/D10368
This commit is contained in:
parent
85b767bbdc
commit
2fdd7f0f3d
1 changed files with 17 additions and 13 deletions
|
@ -294,31 +294,21 @@ abstract class PhabricatorDaemonManagementWorkflow
|
|||
$console = PhutilConsole::getConsole();
|
||||
|
||||
$daemons = $this->loadRunningDaemons();
|
||||
$rogue_daemons = PhutilDaemonOverseer::findRunningDaemons();
|
||||
if (!$daemons) {
|
||||
$rogue_daemons = PhutilDaemonOverseer::findRunningDaemons();
|
||||
if ($force && $rogue_daemons) {
|
||||
$stop_rogue_daemons = $this->buildRogueDaemons($rogue_daemons);
|
||||
$this->sendStopSignals($stop_rogue_daemons, $grace_period);
|
||||
} else {
|
||||
$console->writeErr(pht(
|
||||
'There are no running Phabricator daemons.')."\n");
|
||||
if ($rogue_daemons) {
|
||||
if ($rogue_daemons && !$pids) {
|
||||
$console->writeErr($this->getForceStopHint($rogue_daemons)."\n");
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ($rogue_daemons) {
|
||||
if ($force) {
|
||||
$daemons = array_merge(
|
||||
$daemons,
|
||||
$this->buildRogueDaemons($rogue_daemons));
|
||||
} else {
|
||||
$console->writeErr($this->getForceStopHint($rogue_daemons)."\n");
|
||||
}
|
||||
}
|
||||
|
||||
$daemons = mpull($daemons, null, 'getPID');
|
||||
|
||||
$running = array();
|
||||
|
@ -357,16 +347,30 @@ abstract class PhabricatorDaemonManagementWorkflow
|
|||
}
|
||||
}
|
||||
|
||||
$rogue_daemons = PhutilDaemonOverseer::findRunningDaemons();
|
||||
if ($rogue_daemons) {
|
||||
if ($force) {
|
||||
$stop_rogue_daemons = $this->buildRogueDaemons($rogue_daemons);
|
||||
$this->sendStopSignals($stop_rogue_daemons, $grace_period);
|
||||
} else if (!$pids) {
|
||||
$console->writeErr($this->getForceStopHint($rogue_daemons)."\n");
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private function getForceStopHint($rogue_daemons) {
|
||||
$debug_output = '';
|
||||
foreach ($rogue_daemons as $rogue) {
|
||||
$debug_output .= $rogue['pid'].' '.$rogue['command']."\n";
|
||||
}
|
||||
return pht(
|
||||
'There are processes running that look like Phabricator daemons but '.
|
||||
'have no corresponding PID files:'."\n\n".'%s'."\n\n".
|
||||
'Stop these processes by re-running this command with the --force '.
|
||||
'parameter.',
|
||||
implode("\n", ipull($rogue_daemons, 'command')));
|
||||
$debug_output);
|
||||
}
|
||||
|
||||
private function buildRogueDaemons(array $daemons) {
|
||||
|
|
Loading…
Reference in a new issue