Page MenuHomePhabricator

D9497.id22897.diff
No OneTemporary

D9497.id22897.diff

diff --git a/src/applications/daemon/management/PhabricatorDaemonManagementStatusWorkflow.php b/src/applications/daemon/management/PhabricatorDaemonManagementStatusWorkflow.php
--- a/src/applications/daemon/management/PhabricatorDaemonManagementStatusWorkflow.php
+++ b/src/applications/daemon/management/PhabricatorDaemonManagementStatusWorkflow.php
@@ -7,10 +7,24 @@
$this
->setName('status')
->setSynopsis(pht('Show status of running daemons.'))
- ->setArguments(array());
+ ->setArguments(
+ array(
+ array(
+ 'name' => 'all',
+ 'help' => pht('Show the status of daemons across all hosts.'),
+ ),
+ ));
}
public function execute(PhutilArgumentParser $args) {
+ if ($args->getArg('all')) {
+ return $this->executeGlobal();
+ } else {
+ return $this->executeLocal();
+ }
+ }
+
+ protected function executeLocal() {
$console = PhutilConsole::getConsole();
$daemons = $this->loadRunningDaemons();
@@ -22,12 +36,22 @@
}
$status = 0;
- printf(
- "%-5s\t%-24s\t%-50s%s\n",
- 'PID',
- 'Started',
- 'Daemon',
- 'Arguments');
+ $table = id(new PhutilConsoleTable())
+ ->addColumns(array(
+ 'pid' => array(
+ 'title' => 'PID',
+ ),
+ 'started' => array(
+ 'title' => 'Started',
+ ),
+ 'daemon' => array(
+ 'title' => 'Daemon',
+ ),
+ 'argv' => array(
+ 'title' => 'Arguments',
+ ),
+ ));
+
foreach ($daemons as $daemon) {
$name = $daemon->getName();
if (!$daemon->isRunning()) {
@@ -35,18 +59,67 @@
$status = 2;
$name = '<DEAD> '.$name;
}
- printf(
- "%5s\t%-24s\t%-50s%s\n",
- $daemon->getPID(),
- $daemon->getEpochStarted()
+
+ $table->addData(array(
+ 'pid' => $daemon->getPID(),
+ 'started' => $daemon->getEpochStarted()
? date('M j Y, g:i:s A', $daemon->getEpochStarted())
: null,
- $name,
- csprintf('%LR', $daemon->getArgv()));
+ 'daemon' => $name,
+ 'argv' => csprintf('%LR', $daemon->getArgv()),
+ ));
}
- return $status;
+ $table->draw();
}
+ 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->addData(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();
+ }
}
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
@@ -3,7 +3,7 @@
abstract class PhabricatorDaemonManagementWorkflow
extends PhabricatorManagementWorkflow {
- protected function loadAvailableDaemonClasses() {
+ protected final function loadAvailableDaemonClasses() {
$loader = new PhutilSymbolLoader();
return $loader
->setAncestorClass('PhutilDaemon')
@@ -11,12 +11,12 @@
->selectSymbolsWithoutLoading();
}
- public function getPIDDirectory() {
+ protected final function getPIDDirectory() {
$path = PhabricatorEnv::getEnvConfig('phd.pid-directory');
return $this->getControlDirectory($path);
}
- public function getLogDirectory() {
+ protected final function getLogDirectory() {
$path = PhabricatorEnv::getEnvConfig('phd.log-directory');
return $this->getControlDirectory($path);
}
@@ -35,7 +35,7 @@
return $path;
}
- public function loadRunningDaemons() {
+ protected final function loadRunningDaemons() {
$results = array();
$pid_dir = $this->getPIDDirectory();
@@ -60,6 +60,13 @@
return $results;
}
+ protected final function loadAllRunningDaemons() {
+ return id(new PhabricatorDaemonLogQuery())
+ ->setViewer(PhabricatorUser::getOmnipotentUser())
+ ->withStatus(PhabricatorDaemonLogQuery::STATUS_ALIVE)
+ ->execute();
+ }
+
private function findDaemonClass($substring) {
$symbols = $this->loadAvailableDaemonClasses();
@@ -93,8 +100,7 @@
return head($match);
}
-
- protected function launchDaemon($class, array $argv, $debug) {
+ protected final function launchDaemon($class, array $argv, $debug) {
$daemon = $this->findDaemonClass($class);
$console = PhutilConsole::getConsole();
@@ -212,7 +218,7 @@
}
}
- protected function willLaunchDaemons() {
+ protected final function willLaunchDaemons() {
$console = PhutilConsole::getConsole();
$console->writeErr(pht('Preparing to launch daemons.')."\n");
@@ -224,7 +230,7 @@
/* -( Commands )----------------------------------------------------------- */
- protected function executeStartCommand($keep_leases = false) {
+ protected final function executeStartCommand($keep_leases = false) {
$console = PhutilConsole::getConsole();
$running = $this->loadRunningDaemons();
@@ -278,8 +284,7 @@
return 0;
}
-
- protected function executeStopCommand(array $pids) {
+ protected final function executeStopCommand(array $pids) {
$console = PhutilConsole::getConsole();
$daemons = $this->loadRunningDaemons();

File Metadata

Mime Type
text/plain
Expires
Sat, Dec 21, 2:23 PM (10 h, 9 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6914274
Default Alt Text
D9497.id22897.diff (6 KB)

Event Timeline