2013-07-18 15:28:56 -07:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PhabricatorDaemonManagementStatusWorkflow
|
|
|
|
extends PhabricatorDaemonManagementWorkflow {
|
|
|
|
|
|
|
|
public function didConstruct() {
|
|
|
|
$this
|
|
|
|
->setName('status')
|
|
|
|
->setSynopsis(pht('Show status of running daemons.'))
|
|
|
|
->setArguments(array());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function execute(PhutilArgumentParser $args) {
|
|
|
|
$console = PhutilConsole::getConsole();
|
|
|
|
$daemons = $this->loadRunningDaemons();
|
|
|
|
|
|
|
|
if (!$daemons) {
|
|
|
|
$console->writeErr(
|
|
|
|
"%s\n",
|
2014-06-09 11:36:49 -07:00
|
|
|
pht('There are no running Phabricator daemons.'));
|
2013-07-18 15:28:56 -07:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
$status = 0;
|
Query daemons across all hosts with `./bin/phd status --all`.
Summary: Ref T4209. Currently, `./bin/phd status` prints a table showing the daemons that are executing on the current host. It would be useful to be able to conventiently query the daemons running across all hosts. This would also (theoretically) make it possible to conditionally start daemons on a host depending upon the current state and on the daemons running on other hosts.
Test Plan:
```
> ./bin/phd status --all
ID Host PID Started Daemon Arguments
18 phabricator 6969 Jun 12 2014, 4:44:22 PM PhabricatorTaskmasterDaemon
17 phabricator 6961 Jun 12 2014, 4:44:19 PM PhabricatorTaskmasterDaemon
16 phabricator 6955 Jun 12 2014, 4:44:15 PM PhabricatorTaskmasterDaemon
15 phabricator 6950 Jun 12 2014, 4:44:14 PM PhabricatorTaskmasterDaemon
14 phabricator 6936 Jun 12 2014, 4:44:13 PM PhabricatorGarbageCollectorDaemon
13 phabricator 6931 Jun 12 2014, 4:44:12 PM PhabricatorRepositoryPullLocalDaemon
```
Reviewers: #blessed_reviewers, epriestley
Reviewed By: #blessed_reviewers, epriestley
Subscribers: epriestley, Korvin
Maniphest Tasks: T4209
Differential Revision: https://secure.phabricator.com/D9497
2014-06-17 08:41:51 +10:00
|
|
|
$table = id(new PhutilConsoleTable())
|
|
|
|
->addColumns(array(
|
|
|
|
'pid' => array(
|
|
|
|
'title' => 'PID',
|
|
|
|
),
|
|
|
|
'started' => array(
|
|
|
|
'title' => 'Started',
|
|
|
|
),
|
|
|
|
'daemon' => array(
|
|
|
|
'title' => 'Daemon',
|
|
|
|
),
|
|
|
|
'argv' => array(
|
|
|
|
'title' => 'Arguments',
|
|
|
|
),
|
|
|
|
));
|
|
|
|
|
2013-07-18 15:28:56 -07:00
|
|
|
foreach ($daemons as $daemon) {
|
|
|
|
$name = $daemon->getName();
|
|
|
|
if (!$daemon->isRunning()) {
|
|
|
|
$daemon->updateStatus(PhabricatorDaemonLog::STATUS_DEAD);
|
|
|
|
$status = 2;
|
|
|
|
$name = '<DEAD> '.$name;
|
|
|
|
}
|
Query daemons across all hosts with `./bin/phd status --all`.
Summary: Ref T4209. Currently, `./bin/phd status` prints a table showing the daemons that are executing on the current host. It would be useful to be able to conventiently query the daemons running across all hosts. This would also (theoretically) make it possible to conditionally start daemons on a host depending upon the current state and on the daemons running on other hosts.
Test Plan:
```
> ./bin/phd status --all
ID Host PID Started Daemon Arguments
18 phabricator 6969 Jun 12 2014, 4:44:22 PM PhabricatorTaskmasterDaemon
17 phabricator 6961 Jun 12 2014, 4:44:19 PM PhabricatorTaskmasterDaemon
16 phabricator 6955 Jun 12 2014, 4:44:15 PM PhabricatorTaskmasterDaemon
15 phabricator 6950 Jun 12 2014, 4:44:14 PM PhabricatorTaskmasterDaemon
14 phabricator 6936 Jun 12 2014, 4:44:13 PM PhabricatorGarbageCollectorDaemon
13 phabricator 6931 Jun 12 2014, 4:44:12 PM PhabricatorRepositoryPullLocalDaemon
```
Reviewers: #blessed_reviewers, epriestley
Reviewed By: #blessed_reviewers, epriestley
Subscribers: epriestley, Korvin
Maniphest Tasks: T4209
Differential Revision: https://secure.phabricator.com/D9497
2014-06-17 08:41:51 +10:00
|
|
|
|
|
|
|
$table->addRow(array(
|
|
|
|
'pid' => $daemon->getPID(),
|
|
|
|
'started' => $daemon->getEpochStarted()
|
2013-07-18 15:28:56 -07:00
|
|
|
? date('M j Y, g:i:s A', $daemon->getEpochStarted())
|
|
|
|
: null,
|
Query daemons across all hosts with `./bin/phd status --all`.
Summary: Ref T4209. Currently, `./bin/phd status` prints a table showing the daemons that are executing on the current host. It would be useful to be able to conventiently query the daemons running across all hosts. This would also (theoretically) make it possible to conditionally start daemons on a host depending upon the current state and on the daemons running on other hosts.
Test Plan:
```
> ./bin/phd status --all
ID Host PID Started Daemon Arguments
18 phabricator 6969 Jun 12 2014, 4:44:22 PM PhabricatorTaskmasterDaemon
17 phabricator 6961 Jun 12 2014, 4:44:19 PM PhabricatorTaskmasterDaemon
16 phabricator 6955 Jun 12 2014, 4:44:15 PM PhabricatorTaskmasterDaemon
15 phabricator 6950 Jun 12 2014, 4:44:14 PM PhabricatorTaskmasterDaemon
14 phabricator 6936 Jun 12 2014, 4:44:13 PM PhabricatorGarbageCollectorDaemon
13 phabricator 6931 Jun 12 2014, 4:44:12 PM PhabricatorRepositoryPullLocalDaemon
```
Reviewers: #blessed_reviewers, epriestley
Reviewed By: #blessed_reviewers, epriestley
Subscribers: epriestley, Korvin
Maniphest Tasks: T4209
Differential Revision: https://secure.phabricator.com/D9497
2014-06-17 08:41:51 +10:00
|
|
|
'daemon' => $name,
|
|
|
|
'argv' => csprintf('%LR', $daemon->getArgv()),
|
|
|
|
));
|
2013-07-18 15:28:56 -07:00
|
|
|
}
|
|
|
|
|
Query daemons across all hosts with `./bin/phd status --all`.
Summary: Ref T4209. Currently, `./bin/phd status` prints a table showing the daemons that are executing on the current host. It would be useful to be able to conventiently query the daemons running across all hosts. This would also (theoretically) make it possible to conditionally start daemons on a host depending upon the current state and on the daemons running on other hosts.
Test Plan:
```
> ./bin/phd status --all
ID Host PID Started Daemon Arguments
18 phabricator 6969 Jun 12 2014, 4:44:22 PM PhabricatorTaskmasterDaemon
17 phabricator 6961 Jun 12 2014, 4:44:19 PM PhabricatorTaskmasterDaemon
16 phabricator 6955 Jun 12 2014, 4:44:15 PM PhabricatorTaskmasterDaemon
15 phabricator 6950 Jun 12 2014, 4:44:14 PM PhabricatorTaskmasterDaemon
14 phabricator 6936 Jun 12 2014, 4:44:13 PM PhabricatorGarbageCollectorDaemon
13 phabricator 6931 Jun 12 2014, 4:44:12 PM PhabricatorRepositoryPullLocalDaemon
```
Reviewers: #blessed_reviewers, epriestley
Reviewed By: #blessed_reviewers, epriestley
Subscribers: epriestley, Korvin
Maniphest Tasks: T4209
Differential Revision: https://secure.phabricator.com/D9497
2014-06-17 08:41:51 +10:00
|
|
|
$table->draw();
|
2013-07-18 15:28:56 -07:00
|
|
|
}
|
|
|
|
|
Query daemons across all hosts with `./bin/phd status --all`.
Summary: Ref T4209. Currently, `./bin/phd status` prints a table showing the daemons that are executing on the current host. It would be useful to be able to conventiently query the daemons running across all hosts. This would also (theoretically) make it possible to conditionally start daemons on a host depending upon the current state and on the daemons running on other hosts.
Test Plan:
```
> ./bin/phd status --all
ID Host PID Started Daemon Arguments
18 phabricator 6969 Jun 12 2014, 4:44:22 PM PhabricatorTaskmasterDaemon
17 phabricator 6961 Jun 12 2014, 4:44:19 PM PhabricatorTaskmasterDaemon
16 phabricator 6955 Jun 12 2014, 4:44:15 PM PhabricatorTaskmasterDaemon
15 phabricator 6950 Jun 12 2014, 4:44:14 PM PhabricatorTaskmasterDaemon
14 phabricator 6936 Jun 12 2014, 4:44:13 PM PhabricatorGarbageCollectorDaemon
13 phabricator 6931 Jun 12 2014, 4:44:12 PM PhabricatorRepositoryPullLocalDaemon
```
Reviewers: #blessed_reviewers, epriestley
Reviewed By: #blessed_reviewers, epriestley
Subscribers: epriestley, Korvin
Maniphest Tasks: T4209
Differential Revision: https://secure.phabricator.com/D9497
2014-06-17 08:41:51 +10:00
|
|
|
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();
|
|
|
|
}
|
2013-07-18 15:28:56 -07:00
|
|
|
|
|
|
|
}
|