@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.

Use modern UI elements to show daemons in Daemons

Summary:
Ref T3557. Slightly improves display of daemons:

- Makes status more clear (through colors, explanatory text, icons, and explicit descriptions instead of symbols).
- Particularly, the "wait" status is now communicated as a normal status ("waiting a moment...") with a calm blue color.
- Uses modern responsive elements.

Test Plan: {F51232}

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T3557

Differential Revision: https://secure.phabricator.com/D6539

+83 -98
+6 -6
src/applications/daemon/controller/PhabricatorDaemonConsoleController.php
··· 61 61 '`status` = %s ORDER BY id DESC', 62 62 'run'); 63 63 64 + 65 + $daemon_header = id(new PhabricatorHeaderView()) 66 + ->setHeader(pht('Recent Daemons')); 67 + 64 68 $daemon_table = new PhabricatorDaemonLogListView(); 65 69 $daemon_table->setUser($user); 66 70 $daemon_table->setDaemonLogs($logs); 67 - 68 - $daemon_panel = new AphrontPanelView(); 69 - $daemon_panel->setHeader(pht('Active Daemons')); 70 - $daemon_panel->appendChild($daemon_table); 71 - $daemon_panel->setNoBackground(); 72 71 73 72 $tasks = id(new PhabricatorWorkerActiveTask())->loadAllWhere( 74 73 'leaseOwner IS NOT NULL'); ··· 155 154 $nav->appendChild( 156 155 array( 157 156 $completed_panel, 158 - $daemon_panel, 157 + $daemon_header, 158 + $daemon_table, 159 159 $queued_panel, 160 160 $leased_panel, 161 161 ));
+8 -6
src/applications/daemon/controller/PhabricatorDaemonLogListController.php
··· 24 24 $daemon_table->setUser($request->getUser()); 25 25 $daemon_table->setDaemonLogs($logs); 26 26 27 - $daemon_panel = new AphrontPanelView(); 28 - $daemon_panel->setHeader(pht('All Daemons')); 29 - $daemon_panel->appendChild($daemon_table); 30 - $daemon_panel->appendChild($pager); 31 - $daemon_panel->setNoBackground(); 27 + $crumbs = $this->buildApplicationCrumbs(); 28 + $crumbs->addCrumb( 29 + id(new PhabricatorCrumbView()) 30 + ->setName(pht('All Daemons'))); 32 31 33 32 $nav = $this->buildSideNavView(); 34 33 $nav->selectFilter('log'); 35 - $nav->appendChild($daemon_panel); 34 + $nav->setCrumbs($crumbs); 35 + $nav->appendChild($daemon_table); 36 36 37 37 return $this->buildApplicationPage( 38 38 $nav, 39 39 array( 40 40 'title' => pht('All Daemons'), 41 + 'device' => true, 42 + 'dust' => true, 41 43 )); 42 44 } 43 45
+69 -86
src/applications/daemon/view/PhabricatorDaemonLogListView.php
··· 17 17 throw new Exception("Call setUser() before rendering!"); 18 18 } 19 19 20 + $list = id(new PhabricatorObjectItemListView()); 20 21 foreach ($this->daemonLogs as $log) { 21 - $epoch = $log->getDateCreated(); 22 + 23 + // TODO: VVV Move this stuff to a Query class. VVV 24 + 25 + $expect_heartbeat = (3 * PhutilDaemonOverseer::HEARTBEAT_WAIT); 26 + $assume_dead = (30 * PhutilDaemonOverseer::HEARTBEAT_WAIT); 27 + 28 + $status_running = PhabricatorDaemonLog::STATUS_RUNNING; 29 + $status_unknown = PhabricatorDaemonLog::STATUS_UNKNOWN; 30 + $status_wait = PhabricatorDaemonLog::STATUS_WAIT; 31 + $status_exited = PhabricatorDaemonLog::STATUS_EXITED; 32 + $status_dead = PhabricatorDaemonLog::STATUS_DEAD; 22 33 23 34 $status = $log->getStatus(); 24 - if ($log->getHost() == php_uname('n') && 25 - $status != PhabricatorDaemonLog::STATUS_EXITED && 26 - $status != PhabricatorDaemonLog::STATUS_DEAD) { 35 + $heartbeat_timeout = $log->getDateModified() + $expect_heartbeat; 36 + if ($status == $status_running && $heartbeat_timeout < time()) { 37 + $status = $status_unknown; 38 + } 27 39 28 - $pid = $log->getPID(); 29 - $is_running = PhabricatorDaemonReference::isProcessRunning($pid); 30 - if (!$is_running) { 31 - $guard = AphrontWriteGuard::beginScopedUnguardedWrites(); 32 - $log->setStatus(PhabricatorDaemonLog::STATUS_DEAD); 33 - $log->save(); 34 - unset($guard); 35 - $status = PhabricatorDaemonLog::STATUS_DEAD; 36 - } 40 + if ($status == $status_unknown && $assume_dead < time()) { 41 + $guard = AphrontWriteGuard::beginScopedUnguardedWrites(); 42 + $log->setStatus($status_dead)->save(); 43 + unset($guard); 37 44 } 38 45 39 - $heartbeat_timeout = 40 - $log->getDateModified() + 3 * PhutilDaemonOverseer::HEARTBEAT_WAIT; 41 - if ($status == PhabricatorDaemonLog::STATUS_RUNNING && 42 - $heartbeat_timeout < time()) { 43 - $status = PhabricatorDaemonLog::STATUS_UNKNOWN; 46 + if ($status != $status_running && 47 + $log->getDateModified() + (3 * 86400) < time()) { 48 + // Don't show rows that haven't been running for more than 49 + // three days. We should probably prune these out of the 50 + // DB similar to the code above, but we don't need to be 51 + // conservative and do it only on the same host 52 + 53 + // TODO: This should not apply to the "all daemons" view! 54 + continue; 44 55 } 45 56 57 + // TODO: ^^^^ ALL THAT STUFF ^^^ 58 + 59 + $id = $log->getID(); 60 + $epoch = $log->getDateCreated(); 61 + 62 + $item = id(new PhabricatorObjectItemView()) 63 + ->setObjectName(pht("Daemon %s", $id)) 64 + ->setHeader($log->getDaemon()) 65 + ->setHref("/daemon/log/{$id}/") 66 + ->addIcon('none', phabricator_datetime($epoch, $this->user)); 67 + 46 68 switch ($status) { 47 69 case PhabricatorDaemonLog::STATUS_RUNNING: 48 - $style = 'color: #00cc00'; 49 - $title = 'Running'; 50 - $symbol = "\xE2\x80\xA2"; 70 + $item->setBarColor('green'); 71 + $item->addAttribute(pht('This daemon is running.')); 51 72 break; 52 73 case PhabricatorDaemonLog::STATUS_DEAD: 53 - $style = 'color: #cc0000'; 54 - $title = 'Died'; 55 - $symbol = "\xE2\x80\xA2"; 74 + $item->setBarColor('red'); 75 + $item->addAttribute( 76 + pht( 77 + 'This daemon is lost or exited uncleanly, and is presumed '. 78 + 'dead.')); 79 + $item->addIcon('delete', pht('Dead')); 56 80 break; 57 81 case PhabricatorDaemonLog::STATUS_EXITED: 58 - $style = 'color: #000000'; 59 - $title = 'Exited'; 60 - $symbol = "\xE2\x80\xA2"; 82 + $item->setDisabled(true); 83 + $item->addAttribute(pht('This daemon exited cleanly.')); 84 + $item->addIcon('enable-grey', pht('Exited')); 85 + break; 86 + case PhabricatorDaemonLog::STATUS_WAIT: 87 + $item->setBarColor('blue'); 88 + $item->addAttribute( 89 + pht( 90 + 'This daemon encountered an error recently and is waiting a '. 91 + 'moment to restart.')); 92 + $item->addIcon('perflab-grey', pht('Waiting')); 61 93 break; 62 94 case PhabricatorDaemonLog::STATUS_UNKNOWN: 63 - default: // fallthrough 64 - $style = 'color: #888888'; 65 - $title = 'Unknown'; 66 - $symbol = '?'; 95 + default: 96 + $item->setBarColor('orange'); 97 + $item->addAttribute( 98 + pht( 99 + 'This daemon has not reported its status recently. It may '. 100 + 'have exited uncleanly.')); 101 + $item->addIcon('warning', pht('Unknown')); 102 + break; 67 103 } 68 104 69 - if ($status != PhabricatorDaemonLog::STATUS_RUNNING && 70 - $log->getDateModified() + (3 * 86400) < time()) { 71 - // Don't show rows that haven't been running for more than 72 - // three days. We should probably prune these out of the 73 - // DB similar to the code above, but we don't need to be 74 - // conservative and do it only on the same host 75 - continue; 76 - } 77 - 78 - $running = phutil_tag( 79 - 'span', 80 - array( 81 - 'style' => $style, 82 - 'title' => $title, 83 - ), 84 - $symbol); 85 - 86 - $rows[] = array( 87 - $running, 88 - $log->getDaemon(), 89 - $log->getHost(), 90 - $log->getPID(), 91 - phabricator_date($epoch, $this->user), 92 - phabricator_time($epoch, $this->user), 93 - phutil_tag( 94 - 'a', 95 - array( 96 - 'href' => '/daemon/log/'.$log->getID().'/', 97 - 'class' => 'button small grey', 98 - ), 99 - 'View Log'), 100 - ); 105 + $list->addItem($item); 101 106 } 102 107 103 - $daemon_table = new AphrontTableView($rows); 104 - $daemon_table->setHeaders( 105 - array( 106 - '', 107 - 'Daemon', 108 - 'Host', 109 - 'PID', 110 - 'Date', 111 - 'Time', 112 - 'View', 113 - )); 114 - $daemon_table->setColumnClasses( 115 - array( 116 - '', 117 - 'wide wrap', 118 - '', 119 - '', 120 - '', 121 - 'right', 122 - 'action', 123 - )); 124 - 125 - return $daemon_table->render(); 108 + return $list; 126 109 } 127 110 128 111 }