2013-07-19 00:28:56 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PhabricatorDaemonManagementStatusWorkflow
|
|
|
|
extends PhabricatorDaemonManagementWorkflow {
|
|
|
|
|
|
|
|
public function didConstruct() {
|
|
|
|
$this
|
|
|
|
->setName('status')
|
|
|
|
->setSynopsis(pht('Show status of running daemons.'))
|
Unify the local and global view for `./bin/phd status`.
Summary:
Ref T4209. Unifies the local (`./bin/phd status`) and global (`./bin/phd status --all`) view into a single table. This generally makes it easy to administer daemons running across multiple hosts.
Depends on D9606.
Test Plan:
```
> sudo ./bin/phd status
ID Host PID Started Daemon Arguments
38 localhost 2282 Jun 18 2014, 7:52:56 AM PhabricatorRepositoryPullLocalDaemon
39 localhost 2289 Jun 18 2014, 7:52:57 AM PhabricatorGarbageCollectorDaemon
40 localhost 2294 Jun 18 2014, 7:52:57 AM PhabricatorTaskmasterDaemon
41 localhost 2314 Jun 18 2014, 7:52:58 AM PhabricatorTaskmasterDaemon
42 localhost 2319 Jun 18 2014, 7:52:59 AM PhabricatorTaskmasterDaemon
43 localhost 2328 Jun 18 2014, 7:53:00 AM PhabricatorTaskmasterDaemon
44 localhost 2354 Jun 18 2014, 7:53:08 AM PhabricatorRepositoryPullLocalDaemon X --not Y
```
Reviewers: #blessed_reviewers, epriestley
Reviewed By: #blessed_reviewers, epriestley
Subscribers: epriestley, Korvin
Maniphest Tasks: T4209
Differential Revision: https://secure.phabricator.com/D9607
2014-06-18 03:44:52 +02:00
|
|
|
->setArguments(array());
|
2013-07-19 00:28:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function execute(PhutilArgumentParser $args) {
|
2014-06-17 03:13:38 +02:00
|
|
|
$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) {
|
Unify the local and global view for `./bin/phd status`.
Summary:
Ref T4209. Unifies the local (`./bin/phd status`) and global (`./bin/phd status --all`) view into a single table. This generally makes it easy to administer daemons running across multiple hosts.
Depends on D9606.
Test Plan:
```
> sudo ./bin/phd status
ID Host PID Started Daemon Arguments
38 localhost 2282 Jun 18 2014, 7:52:56 AM PhabricatorRepositoryPullLocalDaemon
39 localhost 2289 Jun 18 2014, 7:52:57 AM PhabricatorGarbageCollectorDaemon
40 localhost 2294 Jun 18 2014, 7:52:57 AM PhabricatorTaskmasterDaemon
41 localhost 2314 Jun 18 2014, 7:52:58 AM PhabricatorTaskmasterDaemon
42 localhost 2319 Jun 18 2014, 7:52:59 AM PhabricatorTaskmasterDaemon
43 localhost 2328 Jun 18 2014, 7:53:00 AM PhabricatorTaskmasterDaemon
44 localhost 2354 Jun 18 2014, 7:53:08 AM PhabricatorRepositoryPullLocalDaemon X --not Y
```
Reviewers: #blessed_reviewers, epriestley
Reviewed By: #blessed_reviewers, epriestley
Subscribers: epriestley, Korvin
Maniphest Tasks: T4209
Differential Revision: https://secure.phabricator.com/D9607
2014-06-18 03:44:52 +02:00
|
|
|
if ($daemon instanceof PhabricatorDaemonLog) {
|
|
|
|
$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', $daemon->getExplicitArgv()),
|
|
|
|
));
|
|
|
|
} else if ($daemon instanceof PhabricatorDaemonReference) {
|
|
|
|
$name = $daemon->getName();
|
|
|
|
if (!$daemon->isRunning()) {
|
|
|
|
$daemon->updateStatus(PhabricatorDaemonLog::STATUS_DEAD);
|
|
|
|
$status = 2;
|
|
|
|
$name = '<DEAD> '.$name;
|
|
|
|
}
|
|
|
|
|
|
|
|
$daemon_log = $daemon->getDaemonLog();
|
|
|
|
$id = null;
|
|
|
|
if ($daemon_log) {
|
|
|
|
$id = $daemon_log->getID();
|
|
|
|
}
|
|
|
|
|
|
|
|
$table->addRow(array(
|
|
|
|
'id' => $id,
|
|
|
|
'host' => 'localhost',
|
|
|
|
'pid' => $daemon->getPID(),
|
|
|
|
'started' => $daemon->getEpochStarted()
|
|
|
|
? date('M j Y, g:i:s A', $daemon->getEpochStarted())
|
|
|
|
: null,
|
|
|
|
'daemon' => $name,
|
|
|
|
'argv' => csprintf('%LR', $daemon->getArgv()),
|
|
|
|
));
|
|
|
|
}
|
2014-06-17 03:13:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$table->draw();
|
|
|
|
}
|
2013-07-19 00:28:56 +02:00
|
|
|
|
|
|
|
}
|