[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/daemon/view/ -> PhabricatorDaemonLogListView.php (source)

   1  <?php
   2  
   3  final class PhabricatorDaemonLogListView extends AphrontView {
   4  
   5    private $daemonLogs;
   6  
   7    public function setDaemonLogs(array $daemon_logs) {
   8      assert_instances_of($daemon_logs, 'PhabricatorDaemonLog');
   9      $this->daemonLogs = $daemon_logs;
  10      return $this;
  11    }
  12  
  13    public function render() {
  14      $rows = array();
  15  
  16      if (!$this->user) {
  17        throw new Exception('Call setUser() before rendering!');
  18      }
  19  
  20      $env_hash = PhabricatorEnv::calculateEnvironmentHash();
  21      $list = new PHUIObjectItemListView();
  22      foreach ($this->daemonLogs as $log) {
  23        $id = $log->getID();
  24        $epoch = $log->getDateCreated();
  25  
  26        $item = id(new PHUIObjectItemView())
  27          ->setObjectName(pht('Daemon %s', $id))
  28          ->setHeader($log->getDaemon())
  29          ->setHref("/daemon/log/{$id}/")
  30          ->addIcon('none', phabricator_datetime($epoch, $this->user));
  31  
  32        $status = $log->getStatus();
  33        switch ($status) {
  34          case PhabricatorDaemonLog::STATUS_RUNNING:
  35            if ($env_hash != $log->getEnvHash()) {
  36              $item->setBarColor('yellow');
  37              $item->addAttribute(pht(
  38                'This daemon is running with an out of date configuration and '.
  39                'should be restarted.'));
  40            } else {
  41              $item->setBarColor('green');
  42              $item->addAttribute(pht('This daemon is running.'));
  43            }
  44            break;
  45          case PhabricatorDaemonLog::STATUS_DEAD:
  46            $item->setBarColor('red');
  47            $item->addAttribute(
  48              pht(
  49                'This daemon is lost or exited uncleanly, and is presumed '.
  50                'dead.'));
  51            $item->addIcon('fa-times grey', pht('Dead'));
  52            break;
  53          case PhabricatorDaemonLog::STATUS_EXITING:
  54            $item->addAttribute(pht('This daemon is exiting.'));
  55            $item->addIcon('fa-check', pht('Exiting'));
  56            break;
  57          case PhabricatorDaemonLog::STATUS_EXITED:
  58            $item->setDisabled(true);
  59            $item->addAttribute(pht('This daemon exited cleanly.'));
  60            $item->addIcon('fa-check grey', pht('Exited'));
  61            break;
  62          case PhabricatorDaemonLog::STATUS_WAIT:
  63            $item->setBarColor('blue');
  64            $item->addAttribute(
  65              pht(
  66                'This daemon encountered an error recently and is waiting a '.
  67                'moment to restart.'));
  68            $item->addIcon('fa-clock-o grey', pht('Waiting'));
  69            break;
  70          case PhabricatorDaemonLog::STATUS_UNKNOWN:
  71          default:
  72            $item->setBarColor('orange');
  73            $item->addAttribute(
  74              pht(
  75                'This daemon has not reported its status recently. It may '.
  76                'have exited uncleanly.'));
  77            $item->addIcon('fa-exclamation-circle', pht('Unknown'));
  78            break;
  79        }
  80  
  81        $list->addItem($item);
  82      }
  83  
  84      return $list;
  85    }
  86  
  87  }


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1