Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/daemon/view/PhabricatorDaemonLogListView.php
12256 views
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
$viewer = $this->getViewer();
15
16
$rows = array();
17
$daemons = $this->daemonLogs;
18
19
foreach ($daemons as $daemon) {
20
$id = $daemon->getID();
21
$host = $daemon->getHost();
22
$pid = $daemon->getPID();
23
$name = phutil_tag(
24
'a',
25
array(
26
'href' => "/daemon/log/{$id}/",
27
),
28
$daemon->getDaemon());
29
30
$status = $daemon->getStatus();
31
switch ($status) {
32
case PhabricatorDaemonLog::STATUS_RUNNING:
33
$status_icon = 'fa-rocket green';
34
$status_label = pht('Running');
35
$status_tip = pht('This daemon is running.');
36
break;
37
case PhabricatorDaemonLog::STATUS_DEAD:
38
$status_icon = 'fa-warning red';
39
$status_label = pht('Dead');
40
$status_tip = pht(
41
'This daemon has been lost or exited uncleanly, and is '.
42
'presumed dead.');
43
break;
44
case PhabricatorDaemonLog::STATUS_EXITING:
45
$status_icon = 'fa-check';
46
$status_label = pht('Shutting Down');
47
$status_tip = pht('This daemon is shutting down.');
48
break;
49
case PhabricatorDaemonLog::STATUS_EXITED:
50
$status_icon = 'fa-check grey';
51
$status_label = pht('Exited');
52
$status_tip = pht('This daemon exited cleanly.');
53
break;
54
case PhabricatorDaemonLog::STATUS_WAIT:
55
$status_icon = 'fa-clock-o blue';
56
$status_label = pht('Waiting');
57
$status_tip = pht(
58
'This daemon encountered an error recently and is waiting a '.
59
'moment to restart.');
60
break;
61
case PhabricatorDaemonLog::STATUS_UNKNOWN:
62
default:
63
$status_icon = 'fa-warning orange';
64
$status_label = pht('Unknown');
65
$status_tip = pht(
66
'This daemon has not reported its status recently. It may '.
67
'have exited uncleanly.');
68
break;
69
}
70
71
$status = phutil_tag(
72
'span',
73
array(
74
'sigil' => 'has-tooltip',
75
'meta' => array(
76
'tip' => $status_tip,
77
),
78
),
79
array(
80
id(new PHUIIconView())->setIcon($status_icon),
81
' ',
82
$status_label,
83
));
84
85
$launched = phabricator_datetime($daemon->getDateCreated(), $viewer);
86
87
$rows[] = array(
88
$id,
89
$host,
90
$pid,
91
$name,
92
$status,
93
$launched,
94
);
95
}
96
97
$table = id(new AphrontTableView($rows))
98
->setHeaders(
99
array(
100
pht('ID'),
101
pht('Host'),
102
pht('PPID'),
103
pht('Daemon'),
104
pht('Status'),
105
pht('Launched'),
106
))
107
->setColumnClasses(
108
array(
109
null,
110
null,
111
null,
112
'pri',
113
'wide',
114
'right date',
115
));
116
117
return $table;
118
}
119
120
}
121
122