1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-11 17:32:41 +01:00
phorge-phorge/src/applications/notification/controller/PhabricatorNotificationStatusController.php
epriestley a1e7a4ccca Version the Aphlict notification server and prompt users to upgrade if they're out of date
Summary: Ref T4324. Add some version information to the server status output, and setup checks to test for an unreachable or out-of-date server.

Test Plan:
  - With server down, hit reasonable setup check.
  - With server up and at a bad version, hit reasonable setup check.
  - Viewed `/notification/status/`.
  - The CSS thing fixes this:

{F114445}

Reviewers: btrahan, chad

Reviewed By: chad

CC: chad, aran

Maniphest Tasks: T4324

Differential Revision: https://secure.phabricator.com/D8251
2014-02-17 15:59:39 -08:00

62 lines
1.5 KiB
PHP

<?php
final class PhabricatorNotificationStatusController
extends PhabricatorNotificationController {
public function processRequest() {
try {
$status = PhabricatorNotificationClient::getServerStatus();
$status = $this->renderServerStatus($status);
} catch (Exception $ex) {
$status = new AphrontErrorView();
$status->setTitle("Notification Server Issue");
$status->appendChild(hsprintf(
'Unable to determine server status. This probably means the server '.
'is not in great shape. The specific issue encountered was:'.
'<br />'.
'<br />'.
'<strong>%s</strong> %s',
get_class($ex),
phutil_escape_html_newlines($ex->getMessage())));
}
return $this->buildStandardPageResponse(
$status,
array(
'title' => 'Aphlict Server Status',
));
}
private function renderServerStatus(array $status) {
$rows = array();
foreach ($status as $key => $value) {
switch ($key) {
case 'uptime':
$value /= 1000;
$value = phabricator_format_relative_time_detailed($value);
break;
case 'log':
break;
default:
$value = number_format($value);
break;
}
$rows[] = array($key, $value);
}
$table = new AphrontTableView($rows);
$table->setColumnClasses(
array(
'header',
'wide',
));
$panel = new AphrontPanelView();
$panel->setHeader('Server Status');
$panel->appendChild($table);
return $panel;
}
}