Differential D9497 Diff 22974 src/applications/daemon/management/PhabricatorDaemonManagementStatusWorkflow.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/daemon/management/PhabricatorDaemonManagementStatusWorkflow.php
<?php | <?php | ||||
final class PhabricatorDaemonManagementStatusWorkflow | final class PhabricatorDaemonManagementStatusWorkflow | ||||
extends PhabricatorDaemonManagementWorkflow { | extends PhabricatorDaemonManagementWorkflow { | ||||
public function didConstruct() { | public function didConstruct() { | ||||
$this | $this | ||||
->setName('status') | ->setName('status') | ||||
->setSynopsis(pht('Show status of running daemons.')) | ->setSynopsis(pht('Show status of running daemons.')) | ||||
->setArguments(array()); | ->setArguments(array()); | ||||
} | } | ||||
joshuaspence: Maybe this doesn't need a separate flag to control this... Possibly we could just show one… | |||||
public function execute(PhutilArgumentParser $args) { | public function execute(PhutilArgumentParser $args) { | ||||
$console = PhutilConsole::getConsole(); | $console = PhutilConsole::getConsole(); | ||||
$daemons = $this->loadRunningDaemons(); | $daemons = $this->loadRunningDaemons(); | ||||
if (!$daemons) { | if (!$daemons) { | ||||
$console->writeErr( | $console->writeErr( | ||||
Not Done Inline ActionsSee above. joshuaspence: See above. | |||||
"%s\n", | "%s\n", | ||||
pht('There are no running Phabricator daemons.')); | pht('There are no running Phabricator daemons.')); | ||||
return 1; | return 1; | ||||
} | } | ||||
$status = 0; | $status = 0; | ||||
printf( | $table = id(new PhutilConsoleTable()) | ||||
"%-5s\t%-24s\t%-50s%s\n", | ->addColumns(array( | ||||
'PID', | 'pid' => array( | ||||
'Started', | 'title' => 'PID', | ||||
'Daemon', | ), | ||||
'Arguments'); | 'started' => array( | ||||
'title' => 'Started', | |||||
), | |||||
'daemon' => array( | |||||
'title' => 'Daemon', | |||||
), | |||||
'argv' => array( | |||||
'title' => 'Arguments', | |||||
), | |||||
)); | |||||
foreach ($daemons as $daemon) { | foreach ($daemons as $daemon) { | ||||
$name = $daemon->getName(); | $name = $daemon->getName(); | ||||
if (!$daemon->isRunning()) { | if (!$daemon->isRunning()) { | ||||
$daemon->updateStatus(PhabricatorDaemonLog::STATUS_DEAD); | $daemon->updateStatus(PhabricatorDaemonLog::STATUS_DEAD); | ||||
$status = 2; | $status = 2; | ||||
$name = '<DEAD> '.$name; | $name = '<DEAD> '.$name; | ||||
} | } | ||||
printf( | |||||
"%5s\t%-24s\t%-50s%s\n", | $table->addRow(array( | ||||
$daemon->getPID(), | 'pid' => $daemon->getPID(), | ||||
$daemon->getEpochStarted() | 'started' => $daemon->getEpochStarted() | ||||
? date('M j Y, g:i:s A', $daemon->getEpochStarted()) | ? date('M j Y, g:i:s A', $daemon->getEpochStarted()) | ||||
: null, | : null, | ||||
$name, | 'daemon' => $name, | ||||
csprintf('%LR', $daemon->getArgv())); | 'argv' => csprintf('%LR', $daemon->getArgv()), | ||||
)); | |||||
} | |||||
$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; | |||||
} | } | ||||
return $status; | $status = 0; | ||||
$table = id(new PhutilConsoleTable()) | |||||
Not Done Inline ActionsThis is getting out of control... Additionally, it's hard to predict how long some of the fields would be (particularly "Host" and "Arguments"). joshuaspence: This is getting out of control... Additionally, it's hard to predict how long some of the… | |||||
->addColumns(array( | |||||
'id' => array( | |||||
'title' => 'ID', | |||||
), | |||||
'host' => array( | |||||
'title' => 'Host', | |||||
), | |||||
'pid' => array( | |||||
'title' => 'PID', | |||||
), | |||||
'started' => array( | |||||
'title' => 'Started', | |||||
), | |||||
'daemon' => array( | |||||
'title' => 'Daemon', | |||||
Not Done Inline Actions$daemon-getArgv() is a little too verbose here. Possibly we could filter out all of the normal argv stuff and just display anything custom? Whether or not this is easier to filter is another question. joshuaspence: `$daemon-getArgv()` is a little too verbose here. Possibly we could filter out all of the… | |||||
), | |||||
'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(); | |||||
} | |||||
} | } |
Maybe this doesn't need a separate flag to control this... Possibly we could just show one unified view which combines information from the database with information from the PID files.