@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+144 -48
+1
src/__phutil_library_map__.php
··· 1026 1026 'PhabricatorDaemonLogEventsView' => 'applications/daemon/view/PhabricatorDaemonLogEventsView.php', 1027 1027 'PhabricatorDaemonLogListController' => 'applications/daemon/controller/PhabricatorDaemonLogListController.php', 1028 1028 'PhabricatorDaemonLogListView' => 'applications/daemon/view/PhabricatorDaemonLogListView.php', 1029 + 'PhabricatorDaemonLogQuery' => 'applications/daemon/query/PhabricatorDaemonLogQuery.php', 1029 1030 'PhabricatorDaemonLogViewController' => 'applications/daemon/controller/PhabricatorDaemonLogViewController.php', 1030 1031 'PhabricatorDaemonManagementDebugWorkflow' => 'applications/daemon/management/PhabricatorDaemonManagementDebugWorkflow.php', 1031 1032 'PhabricatorDaemonManagementLaunchWorkflow' => 'applications/daemon/management/PhabricatorDaemonManagementLaunchWorkflow.php',
+128 -46
src/applications/daemon/controller/PhabricatorDaemonLogViewController.php
··· 22 22 'logID = %d ORDER BY id DESC LIMIT 1000', 23 23 $log->getID()); 24 24 25 - $content = array(); 25 + $crumbs = $this->buildApplicationCrumbs(); 26 + $crumbs->addCrumb( 27 + id(new PhabricatorCrumbView()) 28 + ->setName(pht('Daemon %s', $log->getID()))); 26 29 27 - $argv = $log->getArgv(); 28 - if (is_array($argv)) { 29 - $argv = implode("\n", $argv); 30 - } 30 + $header = id(new PhabricatorHeaderView()) 31 + ->setHeader($log->getDaemon()); 31 32 32 - $form = id(new AphrontFormView()) 33 - ->setUser($user) 34 - ->appendChild( 35 - id(new AphrontFormStaticControl()) 36 - ->setLabel(pht('Daemon')) 37 - ->setValue($log->getDaemon())) 38 - ->appendChild( 39 - id(new AphrontFormStaticControl()) 40 - ->setLabel(pht('Host')) 41 - ->setValue($log->getHost())) 42 - ->appendChild( 43 - id(new AphrontFormStaticControl()) 44 - ->setLabel(pht('PID')) 45 - ->setValue($log->getPID())) 46 - ->appendChild( 47 - id(new AphrontFormStaticControl()) 48 - ->setLabel(pht('Started')) 49 - ->setValue( 50 - phabricator_datetime($log->getDateCreated(), $user))) 51 - ->appendChild( 52 - id(new AphrontFormTextAreaControl()) 53 - ->setLabel(pht('Argv')) 54 - ->setValue($argv)); 33 + $tag = id(new PhabricatorTagView()) 34 + ->setType(PhabricatorTagView::TYPE_STATE); 55 35 56 - $panel = new AphrontPanelView(); 57 - $panel->setHeader(pht('Daemon Details')); 58 - $panel->setNoBackground(); 59 - $panel->appendChild($form); 36 + $status = $log->getStatus(); 37 + switch ($status) { 38 + case PhabricatorDaemonLog::STATUS_UNKNOWN: 39 + $tag->setBackgroundColor(PhabricatorTagView::COLOR_ORANGE); 40 + $tag->setName(pht('Unknown')); 41 + break; 42 + case PhabricatorDaemonLog::STATUS_RUNNING: 43 + $tag->setBackgroundColor(PhabricatorTagView::COLOR_GREEN); 44 + $tag->setName(pht('Running')); 45 + break; 46 + case PhabricatorDaemonLog::STATUS_DEAD: 47 + $tag->setBackgroundColor(PhabricatorTagView::COLOR_RED); 48 + $tag->setName(pht('Dead')); 49 + break; 50 + case PhabricatorDaemonLog::STATUS_WAIT: 51 + $tag->setBackgroundColor(PhabricatorTagView::COLOR_BLUE); 52 + $tag->setName(pht('Waiting')); 53 + break; 54 + case PhabricatorDaemonLog::STATUS_EXITED: 55 + $tag->setBackgroundColor(PhabricatorTagView::COLOR_GREY); 56 + $tag->setName(pht('Exited')); 57 + break; 58 + } 60 59 61 - $content[] = $panel; 60 + $header->addTag($tag); 62 61 63 - $event_view = new PhabricatorDaemonLogEventsView(); 64 - $event_view->setUser($user); 65 - $event_view->setEvents($events); 62 + $properties = $this->buildPropertyListView($log); 66 63 67 - $log_panel = new AphrontPanelView(); 68 - $log_panel->setHeader(pht('Daemon Logs')); 69 - $log_panel->setNoBackground(); 70 - $log_panel->appendChild($event_view); 64 + $event_view = id(new PhabricatorDaemonLogEventsView()) 65 + ->setUser($user) 66 + ->setEvents($events); 71 67 72 - $content[] = $log_panel; 73 - 74 - $nav = $this->buildSideNavView(); 75 - $nav->selectFilter('log'); 76 - $nav->appendChild($content); 68 + $event_panel = new AphrontPanelView(); 69 + $event_panel->setNoBackground(); 70 + $event_panel->appendChild($event_view); 77 71 78 72 return $this->buildApplicationPage( 79 - $nav, 73 + array( 74 + $crumbs, 75 + $header, 76 + $properties, 77 + $event_panel, 78 + ), 80 79 array( 81 80 'title' => pht('Daemon Log'), 82 81 )); 82 + } 83 + 84 + private function buildPropertyListView(PhabricatorDaemonLog $daemon) { 85 + $request = $this->getRequest(); 86 + $viewer = $request->getUser(); 87 + 88 + $view = id(new PhabricatorPropertyListView()) 89 + ->setUser($viewer); 90 + 91 + $c_epoch = $daemon->getDateCreated(); 92 + $u_epoch = $daemon->getDateModified(); 93 + 94 + $unknown_time = PhabricatorDaemonLogQuery::getTimeUntilUnknown(); 95 + $dead_time = PhabricatorDaemonLogQuery::getTimeUntilDead(); 96 + 97 + $details = null; 98 + $status = $daemon->getStatus(); 99 + switch ($status) { 100 + case PhabricatorDaemonLog::STATUS_RUNNING: 101 + $details = pht( 102 + 'This daemon is running normally and reported a status update '. 103 + 'recently (within %s).', 104 + phabricator_format_relative_time($unknown_time)); 105 + break; 106 + case PhabricatorDaemonLog::STATUS_UNKNOWN: 107 + $details = pht( 108 + 'This daemon has not reported a status update recently (within %s). '. 109 + 'It may have exited abruptly. After %s, it will be presumed dead.', 110 + phabricator_format_relative_time($unknown_time), 111 + phabricator_format_relative_time($dead_time)); 112 + break; 113 + case PhabricatorDaemonLog::STATUS_DEAD: 114 + $details = pht( 115 + 'This daemon did not report a status update for %s. It is '. 116 + 'presumed dead. Usually, this indicates that the daemon was '. 117 + 'killed or otherwise exited abruptly with an error. You may '. 118 + 'need to restart it.', 119 + phabricator_format_relative_time($dead_time)); 120 + break; 121 + case PhabricatorDaemonLog::STATUS_WAIT: 122 + $details = pht( 123 + 'This daemon is running normally and reported a status update '. 124 + 'recently (within %s). However, it encountered an error while '. 125 + 'doing work and is waiting a little while to resume processing. '. 126 + 'After encountering an error, daemons wait before resuming work '. 127 + 'to avoid overloading services.', 128 + phabricator_format_relative_time($unknown_time)); 129 + break; 130 + case PhabricatorDaemonLog::STATUS_EXITED: 131 + $details = pht( 132 + 'This daemon exited normally and is no longer running.'); 133 + break; 134 + } 135 + 136 + $view->addProperty(pht('Status Details'), $details); 137 + 138 + $view->addProperty(pht('Daemon Class'), $daemon->getDaemon()); 139 + $view->addProperty(pht('Host'), $daemon->getHost()); 140 + $view->addProperty(pht('PID'), $daemon->getPID()); 141 + $view->addProperty(pht('Started'), phabricator_datetime($c_epoch, $viewer)); 142 + $view->addProperty( 143 + pht('Seen'), 144 + pht( 145 + '%s ago (%s)', 146 + phabricator_format_relative_time(time() - $u_epoch), 147 + phabricator_datetime($u_epoch, $viewer))); 148 + 149 + $argv = $daemon->getArgv(); 150 + if (is_array($argv)) { 151 + $argv = implode("\n", $argv); 152 + } 153 + 154 + $view->addProperty( 155 + pht('Argv'), 156 + phutil_tag( 157 + 'textarea', 158 + array( 159 + 'style' => 'width: 100%; height: 12em;', 160 + ), 161 + $argv)); 162 + 163 + 164 + return $view; 83 165 } 84 166 85 167 }
+13
src/applications/daemon/query/PhabricatorDaemonLogQuery.php
··· 1 + <?php 2 + 3 + final class PhabricatorDaemonLogQuery { 4 + 5 + public static function getTimeUntilUnknown() { 6 + return 3 * PhutilDaemonOverseer::HEARTBEAT_WAIT; 7 + } 8 + 9 + public static function getTimeUntilDead() { 10 + return 30 * PhutilDaemonOverseer::HEARTBEAT_WAIT; 11 + } 12 + 13 + }
+2 -2
src/applications/daemon/view/PhabricatorDaemonLogListView.php
··· 22 22 23 23 // TODO: VVV Move this stuff to a Query class. VVV 24 24 25 - $expect_heartbeat = (3 * PhutilDaemonOverseer::HEARTBEAT_WAIT); 26 - $assume_dead = (30 * PhutilDaemonOverseer::HEARTBEAT_WAIT); 25 + $expect_heartbeat = PhabricatorDaemonLogQuery::getTimeUntilUnknown(); 26 + $assume_dead = PhabricatorDaemonLogQuery::getTimeUntilDead(); 27 27 28 28 $status_running = PhabricatorDaemonLog::STATUS_RUNNING; 29 29 $status_unknown = PhabricatorDaemonLog::STATUS_UNKNOWN;