1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-22 05:20:56 +01:00

Mostly modernize daemon detail views

Summary:
Ref T3557. The major goals here are:

  - Modernize use of UI elements.
  - Present daemon status with more clarity. Particularly, the "Waiting" status is called out and explained in detail.

Test Plan:
{F51247}

{F51248}

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T3557

Differential Revision: https://secure.phabricator.com/D6541
This commit is contained in:
epriestley 2013-07-23 12:10:41 -07:00
parent 9a35da73ae
commit 40226bbfd0
4 changed files with 146 additions and 50 deletions

View file

@ -1026,6 +1026,7 @@ phutil_register_library_map(array(
'PhabricatorDaemonLogEventsView' => 'applications/daemon/view/PhabricatorDaemonLogEventsView.php',
'PhabricatorDaemonLogListController' => 'applications/daemon/controller/PhabricatorDaemonLogListController.php',
'PhabricatorDaemonLogListView' => 'applications/daemon/view/PhabricatorDaemonLogListView.php',
'PhabricatorDaemonLogQuery' => 'applications/daemon/query/PhabricatorDaemonLogQuery.php',
'PhabricatorDaemonLogViewController' => 'applications/daemon/controller/PhabricatorDaemonLogViewController.php',
'PhabricatorDaemonManagementDebugWorkflow' => 'applications/daemon/management/PhabricatorDaemonManagementDebugWorkflow.php',
'PhabricatorDaemonManagementLaunchWorkflow' => 'applications/daemon/management/PhabricatorDaemonManagementLaunchWorkflow.php',

View file

@ -22,64 +22,146 @@ final class PhabricatorDaemonLogViewController
'logID = %d ORDER BY id DESC LIMIT 1000',
$log->getID());
$content = array();
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addCrumb(
id(new PhabricatorCrumbView())
->setName(pht('Daemon %s', $log->getID())));
$argv = $log->getArgv();
if (is_array($argv)) {
$argv = implode("\n", $argv);
$header = id(new PhabricatorHeaderView())
->setHeader($log->getDaemon());
$tag = id(new PhabricatorTagView())
->setType(PhabricatorTagView::TYPE_STATE);
$status = $log->getStatus();
switch ($status) {
case PhabricatorDaemonLog::STATUS_UNKNOWN:
$tag->setBackgroundColor(PhabricatorTagView::COLOR_ORANGE);
$tag->setName(pht('Unknown'));
break;
case PhabricatorDaemonLog::STATUS_RUNNING:
$tag->setBackgroundColor(PhabricatorTagView::COLOR_GREEN);
$tag->setName(pht('Running'));
break;
case PhabricatorDaemonLog::STATUS_DEAD:
$tag->setBackgroundColor(PhabricatorTagView::COLOR_RED);
$tag->setName(pht('Dead'));
break;
case PhabricatorDaemonLog::STATUS_WAIT:
$tag->setBackgroundColor(PhabricatorTagView::COLOR_BLUE);
$tag->setName(pht('Waiting'));
break;
case PhabricatorDaemonLog::STATUS_EXITED:
$tag->setBackgroundColor(PhabricatorTagView::COLOR_GREY);
$tag->setName(pht('Exited'));
break;
}
$form = id(new AphrontFormView())
$header->addTag($tag);
$properties = $this->buildPropertyListView($log);
$event_view = id(new PhabricatorDaemonLogEventsView())
->setUser($user)
->appendChild(
id(new AphrontFormStaticControl())
->setLabel(pht('Daemon'))
->setValue($log->getDaemon()))
->appendChild(
id(new AphrontFormStaticControl())
->setLabel(pht('Host'))
->setValue($log->getHost()))
->appendChild(
id(new AphrontFormStaticControl())
->setLabel(pht('PID'))
->setValue($log->getPID()))
->appendChild(
id(new AphrontFormStaticControl())
->setLabel(pht('Started'))
->setValue(
phabricator_datetime($log->getDateCreated(), $user)))
->appendChild(
id(new AphrontFormTextAreaControl())
->setLabel(pht('Argv'))
->setValue($argv));
->setEvents($events);
$panel = new AphrontPanelView();
$panel->setHeader(pht('Daemon Details'));
$panel->setNoBackground();
$panel->appendChild($form);
$content[] = $panel;
$event_view = new PhabricatorDaemonLogEventsView();
$event_view->setUser($user);
$event_view->setEvents($events);
$log_panel = new AphrontPanelView();
$log_panel->setHeader(pht('Daemon Logs'));
$log_panel->setNoBackground();
$log_panel->appendChild($event_view);
$content[] = $log_panel;
$nav = $this->buildSideNavView();
$nav->selectFilter('log');
$nav->appendChild($content);
$event_panel = new AphrontPanelView();
$event_panel->setNoBackground();
$event_panel->appendChild($event_view);
return $this->buildApplicationPage(
$nav,
array(
$crumbs,
$header,
$properties,
$event_panel,
),
array(
'title' => pht('Daemon Log'),
));
}
private function buildPropertyListView(PhabricatorDaemonLog $daemon) {
$request = $this->getRequest();
$viewer = $request->getUser();
$view = id(new PhabricatorPropertyListView())
->setUser($viewer);
$c_epoch = $daemon->getDateCreated();
$u_epoch = $daemon->getDateModified();
$unknown_time = PhabricatorDaemonLogQuery::getTimeUntilUnknown();
$dead_time = PhabricatorDaemonLogQuery::getTimeUntilDead();
$details = null;
$status = $daemon->getStatus();
switch ($status) {
case PhabricatorDaemonLog::STATUS_RUNNING:
$details = pht(
'This daemon is running normally and reported a status update '.
'recently (within %s).',
phabricator_format_relative_time($unknown_time));
break;
case PhabricatorDaemonLog::STATUS_UNKNOWN:
$details = pht(
'This daemon has not reported a status update recently (within %s). '.
'It may have exited abruptly. After %s, it will be presumed dead.',
phabricator_format_relative_time($unknown_time),
phabricator_format_relative_time($dead_time));
break;
case PhabricatorDaemonLog::STATUS_DEAD:
$details = pht(
'This daemon did not report a status update for %s. It is '.
'presumed dead. Usually, this indicates that the daemon was '.
'killed or otherwise exited abruptly with an error. You may '.
'need to restart it.',
phabricator_format_relative_time($dead_time));
break;
case PhabricatorDaemonLog::STATUS_WAIT:
$details = pht(
'This daemon is running normally and reported a status update '.
'recently (within %s). However, it encountered an error while '.
'doing work and is waiting a little while to resume processing. '.
'After encountering an error, daemons wait before resuming work '.
'to avoid overloading services.',
phabricator_format_relative_time($unknown_time));
break;
case PhabricatorDaemonLog::STATUS_EXITED:
$details = pht(
'This daemon exited normally and is no longer running.');
break;
}
$view->addProperty(pht('Status Details'), $details);
$view->addProperty(pht('Daemon Class'), $daemon->getDaemon());
$view->addProperty(pht('Host'), $daemon->getHost());
$view->addProperty(pht('PID'), $daemon->getPID());
$view->addProperty(pht('Started'), phabricator_datetime($c_epoch, $viewer));
$view->addProperty(
pht('Seen'),
pht(
'%s ago (%s)',
phabricator_format_relative_time(time() - $u_epoch),
phabricator_datetime($u_epoch, $viewer)));
$argv = $daemon->getArgv();
if (is_array($argv)) {
$argv = implode("\n", $argv);
}
$view->addProperty(
pht('Argv'),
phutil_tag(
'textarea',
array(
'style' => 'width: 100%; height: 12em;',
),
$argv));
return $view;
}
}

View file

@ -0,0 +1,13 @@
<?php
final class PhabricatorDaemonLogQuery {
public static function getTimeUntilUnknown() {
return 3 * PhutilDaemonOverseer::HEARTBEAT_WAIT;
}
public static function getTimeUntilDead() {
return 30 * PhutilDaemonOverseer::HEARTBEAT_WAIT;
}
}

View file

@ -22,8 +22,8 @@ final class PhabricatorDaemonLogListView extends AphrontView {
// TODO: VVV Move this stuff to a Query class. VVV
$expect_heartbeat = (3 * PhutilDaemonOverseer::HEARTBEAT_WAIT);
$assume_dead = (30 * PhutilDaemonOverseer::HEARTBEAT_WAIT);
$expect_heartbeat = PhabricatorDaemonLogQuery::getTimeUntilUnknown();
$assume_dead = PhabricatorDaemonLogQuery::getTimeUntilDead();
$status_running = PhabricatorDaemonLog::STATUS_RUNNING;
$status_unknown = PhabricatorDaemonLog::STATUS_UNKNOWN;