Path: blob/master/src/applications/daemon/view/PhabricatorDaemonLogListView.php
12256 views
<?php12final class PhabricatorDaemonLogListView extends AphrontView {34private $daemonLogs;56public function setDaemonLogs(array $daemon_logs) {7assert_instances_of($daemon_logs, 'PhabricatorDaemonLog');8$this->daemonLogs = $daemon_logs;9return $this;10}1112public function render() {13$viewer = $this->getViewer();1415$rows = array();16$daemons = $this->daemonLogs;1718foreach ($daemons as $daemon) {19$id = $daemon->getID();20$host = $daemon->getHost();21$pid = $daemon->getPID();22$name = phutil_tag(23'a',24array(25'href' => "/daemon/log/{$id}/",26),27$daemon->getDaemon());2829$status = $daemon->getStatus();30switch ($status) {31case PhabricatorDaemonLog::STATUS_RUNNING:32$status_icon = 'fa-rocket green';33$status_label = pht('Running');34$status_tip = pht('This daemon is running.');35break;36case PhabricatorDaemonLog::STATUS_DEAD:37$status_icon = 'fa-warning red';38$status_label = pht('Dead');39$status_tip = pht(40'This daemon has been lost or exited uncleanly, and is '.41'presumed dead.');42break;43case PhabricatorDaemonLog::STATUS_EXITING:44$status_icon = 'fa-check';45$status_label = pht('Shutting Down');46$status_tip = pht('This daemon is shutting down.');47break;48case PhabricatorDaemonLog::STATUS_EXITED:49$status_icon = 'fa-check grey';50$status_label = pht('Exited');51$status_tip = pht('This daemon exited cleanly.');52break;53case PhabricatorDaemonLog::STATUS_WAIT:54$status_icon = 'fa-clock-o blue';55$status_label = pht('Waiting');56$status_tip = pht(57'This daemon encountered an error recently and is waiting a '.58'moment to restart.');59break;60case PhabricatorDaemonLog::STATUS_UNKNOWN:61default:62$status_icon = 'fa-warning orange';63$status_label = pht('Unknown');64$status_tip = pht(65'This daemon has not reported its status recently. It may '.66'have exited uncleanly.');67break;68}6970$status = phutil_tag(71'span',72array(73'sigil' => 'has-tooltip',74'meta' => array(75'tip' => $status_tip,76),77),78array(79id(new PHUIIconView())->setIcon($status_icon),80' ',81$status_label,82));8384$launched = phabricator_datetime($daemon->getDateCreated(), $viewer);8586$rows[] = array(87$id,88$host,89$pid,90$name,91$status,92$launched,93);94}9596$table = id(new AphrontTableView($rows))97->setHeaders(98array(99pht('ID'),100pht('Host'),101pht('PPID'),102pht('Daemon'),103pht('Status'),104pht('Launched'),105))106->setColumnClasses(107array(108null,109null,110null,111'pri',112'wide',113'right date',114));115116return $table;117}118119}120121122