mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-18 12:52:42 +01:00
Revert "Query daemons across all hosts with ./bin/phd status --all
."
This reverts commit 0ccebbe4b1
.
This commit is contained in:
parent
0ccebbe4b1
commit
a10f969919
3 changed files with 39 additions and 113 deletions
|
@ -22,22 +22,12 @@ final class PhabricatorDaemonManagementStatusWorkflow
|
|||
}
|
||||
|
||||
$status = 0;
|
||||
$table = id(new PhutilConsoleTable())
|
||||
->addColumns(array(
|
||||
'pid' => array(
|
||||
'title' => 'PID',
|
||||
),
|
||||
'started' => array(
|
||||
'title' => 'Started',
|
||||
),
|
||||
'daemon' => array(
|
||||
'title' => 'Daemon',
|
||||
),
|
||||
'argv' => array(
|
||||
'title' => 'Arguments',
|
||||
),
|
||||
));
|
||||
|
||||
printf(
|
||||
"%-5s\t%-24s\t%-50s%s\n",
|
||||
'PID',
|
||||
'Started',
|
||||
'Daemon',
|
||||
'Arguments');
|
||||
foreach ($daemons as $daemon) {
|
||||
$name = $daemon->getName();
|
||||
if (!$daemon->isRunning()) {
|
||||
|
@ -45,67 +35,18 @@ final class PhabricatorDaemonManagementStatusWorkflow
|
|||
$status = 2;
|
||||
$name = '<DEAD> '.$name;
|
||||
}
|
||||
|
||||
$table->addRow(array(
|
||||
'pid' => $daemon->getPID(),
|
||||
'started' => $daemon->getEpochStarted()
|
||||
printf(
|
||||
"%5s\t%-24s\t%-50s%s\n",
|
||||
$daemon->getPID(),
|
||||
$daemon->getEpochStarted()
|
||||
? date('M j Y, g:i:s A', $daemon->getEpochStarted())
|
||||
: null,
|
||||
'daemon' => $name,
|
||||
'argv' => csprintf('%LR', $daemon->getArgv()),
|
||||
));
|
||||
$name,
|
||||
csprintf('%LR', $daemon->getArgv()));
|
||||
}
|
||||
|
||||
$table->draw();
|
||||
return $status;
|
||||
}
|
||||
|
||||
protected function executeGlobal() {
|
||||
$console = PhutilConsole::getConsole();
|
||||
$daemons = $this->loadAllRunningDaemons();
|
||||
|
||||
if (!$daemons) {
|
||||
$console->writeErr(
|
||||
"%s\n",
|
||||
pht('There are no running Phabricator daemons.'));
|
||||
return 1;
|
||||
}
|
||||
|
||||
$status = 0;
|
||||
|
||||
$table = id(new PhutilConsoleTable())
|
||||
->addColumns(array(
|
||||
'id' => array(
|
||||
'title' => 'ID',
|
||||
),
|
||||
'host' => array(
|
||||
'title' => 'Host',
|
||||
),
|
||||
'pid' => array(
|
||||
'title' => 'PID',
|
||||
),
|
||||
'started' => array(
|
||||
'title' => 'Started',
|
||||
),
|
||||
'daemon' => array(
|
||||
'title' => 'Daemon',
|
||||
),
|
||||
'argv' => array(
|
||||
'title' => 'Arguments',
|
||||
),
|
||||
));
|
||||
|
||||
foreach ($daemons as $daemon) {
|
||||
$table->addRow(array(
|
||||
'id' => $daemon->getID(),
|
||||
'host' => $daemon->getHost(),
|
||||
'pid' => $daemon->getPID(),
|
||||
'started' => date('M j Y, g:i:s A', $daemon->getDateCreated()),
|
||||
'daemon' => $daemon->getDaemon(),
|
||||
'argv' => csprintf('%LR', array() /* $daemon->getArgv() */),
|
||||
));
|
||||
}
|
||||
|
||||
$table->draw();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
abstract class PhabricatorDaemonManagementWorkflow
|
||||
extends PhabricatorManagementWorkflow {
|
||||
|
||||
protected final function loadAvailableDaemonClasses() {
|
||||
protected function loadAvailableDaemonClasses() {
|
||||
$loader = new PhutilSymbolLoader();
|
||||
return $loader
|
||||
->setAncestorClass('PhutilDaemon')
|
||||
|
@ -11,12 +11,12 @@ abstract class PhabricatorDaemonManagementWorkflow
|
|||
->selectSymbolsWithoutLoading();
|
||||
}
|
||||
|
||||
protected final function getPIDDirectory() {
|
||||
public function getPIDDirectory() {
|
||||
$path = PhabricatorEnv::getEnvConfig('phd.pid-directory');
|
||||
return $this->getControlDirectory($path);
|
||||
}
|
||||
|
||||
protected final function getLogDirectory() {
|
||||
public function getLogDirectory() {
|
||||
$path = PhabricatorEnv::getEnvConfig('phd.log-directory');
|
||||
return $this->getControlDirectory($path);
|
||||
}
|
||||
|
@ -35,9 +35,8 @@ abstract class PhabricatorDaemonManagementWorkflow
|
|||
return $path;
|
||||
}
|
||||
|
||||
protected final function loadRunningDaemons() {
|
||||
public function loadRunningDaemons() {
|
||||
$results = array();
|
||||
$ids = array();
|
||||
|
||||
$pid_dir = $this->getPIDDirectory();
|
||||
$pid_files = Filesystem::listDirectory($pid_dir);
|
||||
|
@ -46,17 +45,19 @@ abstract class PhabricatorDaemonManagementWorkflow
|
|||
}
|
||||
|
||||
foreach ($pid_files as $pid_file) {
|
||||
$results[] = PhabricatorDaemonReference::newFromDictionary(
|
||||
$pid_dir.'/'.$pid_file);
|
||||
$ids[] = $ref->getDaemonLog()->getID();
|
||||
$pid_data = Filesystem::readFile($pid_dir.'/'.$pid_file);
|
||||
$dict = json_decode($pid_data, true);
|
||||
if (!is_array($dict)) {
|
||||
// Just return a hanging reference, since control code needs to be
|
||||
// robust against unusual system states.
|
||||
$dict = array();
|
||||
}
|
||||
$ref = PhabricatorDaemonReference::newFromDictionary($dict);
|
||||
$ref->setPIDFile($pid_dir.'/'.$pid_file);
|
||||
$results[] = $ref;
|
||||
}
|
||||
|
||||
$other = id(new PhabricatorDaemonLogQuery())
|
||||
->setViewer(PhabricatorUser::getOmnipotentUser())
|
||||
->withStatus(PhabricatorDaemonLogQuery::STATUS_ALIVE)
|
||||
->execute();
|
||||
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
private function findDaemonClass($substring) {
|
||||
|
@ -92,7 +93,8 @@ abstract class PhabricatorDaemonManagementWorkflow
|
|||
return head($match);
|
||||
}
|
||||
|
||||
protected final function launchDaemon($class, array $argv, $debug) {
|
||||
|
||||
protected function launchDaemon($class, array $argv, $debug) {
|
||||
$daemon = $this->findDaemonClass($class);
|
||||
$console = PhutilConsole::getConsole();
|
||||
|
||||
|
@ -210,7 +212,7 @@ abstract class PhabricatorDaemonManagementWorkflow
|
|||
}
|
||||
}
|
||||
|
||||
protected final function willLaunchDaemons() {
|
||||
protected function willLaunchDaemons() {
|
||||
$console = PhutilConsole::getConsole();
|
||||
$console->writeErr(pht('Preparing to launch daemons.')."\n");
|
||||
|
||||
|
@ -222,7 +224,7 @@ abstract class PhabricatorDaemonManagementWorkflow
|
|||
/* -( Commands )----------------------------------------------------------- */
|
||||
|
||||
|
||||
protected final function executeStartCommand($keep_leases = false) {
|
||||
protected function executeStartCommand($keep_leases = false) {
|
||||
$console = PhutilConsole::getConsole();
|
||||
|
||||
$running = $this->loadRunningDaemons();
|
||||
|
@ -276,7 +278,8 @@ abstract class PhabricatorDaemonManagementWorkflow
|
|||
return 0;
|
||||
}
|
||||
|
||||
protected final function executeStopCommand(array $pids) {
|
||||
|
||||
protected function executeStopCommand(array $pids) {
|
||||
$console = PhutilConsole::getConsole();
|
||||
|
||||
$daemons = $this->loadRunningDaemons();
|
||||
|
|
|
@ -10,19 +10,6 @@ final class PhabricatorDaemonReference {
|
|||
|
||||
private $daemonLog;
|
||||
|
||||
public static function newFromFile($path) {
|
||||
$pid_data = Filesystem::readFile($path);
|
||||
$dict = json_decode($pid_data, true);
|
||||
if (!is_array($dict)) {
|
||||
// Just return a hanging reference, since control code needs to be
|
||||
// robust against unusual system states.
|
||||
$dict = array();
|
||||
}
|
||||
$ref = self::newFromDictionary($dict);
|
||||
$ref->pidFile = $path;
|
||||
return $ref;
|
||||
}
|
||||
|
||||
public static function newFromDictionary(array $dict) {
|
||||
$ref = new PhabricatorDaemonReference();
|
||||
|
||||
|
@ -31,12 +18,6 @@ final class PhabricatorDaemonReference {
|
|||
$ref->pid = idx($dict, 'pid');
|
||||
$ref->start = idx($dict, 'start');
|
||||
|
||||
$this->daemonLog = id(new PhabricatorDaemonLog())->loadOneWhere(
|
||||
'daemon = %s AND pid = %d AND dateCreated = %d',
|
||||
$this->name,
|
||||
$this->pid,
|
||||
$this->start);
|
||||
|
||||
return $ref;
|
||||
}
|
||||
|
||||
|
@ -85,12 +66,13 @@ final class PhabricatorDaemonReference {
|
|||
return $this->start;
|
||||
}
|
||||
|
||||
public function getPIDFile() {
|
||||
return $this->pidFile;
|
||||
public function setPIDFile($pid_file) {
|
||||
$this->pidFile = $pid_file;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDaemonLog() {
|
||||
return $this->daemonLog;
|
||||
public function getPIDFile() {
|
||||
return $this->pidFile;
|
||||
}
|
||||
|
||||
public function isRunning() {
|
||||
|
|
Loading…
Reference in a new issue