mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 06:42:42 +01:00
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
This commit is contained in:
parent
f3cbc0e006
commit
a1e7a4ccca
6 changed files with 100 additions and 17 deletions
|
@ -1698,6 +1698,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorNoteExample' => 'applications/uiexample/examples/PhabricatorNoteExample.php',
|
'PhabricatorNoteExample' => 'applications/uiexample/examples/PhabricatorNoteExample.php',
|
||||||
'PhabricatorNotificationBuilder' => 'applications/notification/builder/PhabricatorNotificationBuilder.php',
|
'PhabricatorNotificationBuilder' => 'applications/notification/builder/PhabricatorNotificationBuilder.php',
|
||||||
'PhabricatorNotificationClearController' => 'applications/notification/controller/PhabricatorNotificationClearController.php',
|
'PhabricatorNotificationClearController' => 'applications/notification/controller/PhabricatorNotificationClearController.php',
|
||||||
|
'PhabricatorNotificationClient' => 'applications/notification/client/PhabricatorNotificationClient.php',
|
||||||
'PhabricatorNotificationConfigOptions' => 'applications/config/option/PhabricatorNotificationConfigOptions.php',
|
'PhabricatorNotificationConfigOptions' => 'applications/config/option/PhabricatorNotificationConfigOptions.php',
|
||||||
'PhabricatorNotificationController' => 'applications/notification/controller/PhabricatorNotificationController.php',
|
'PhabricatorNotificationController' => 'applications/notification/controller/PhabricatorNotificationController.php',
|
||||||
'PhabricatorNotificationIndividualController' => 'applications/notification/controller/PhabricatorNotificationIndividualController.php',
|
'PhabricatorNotificationIndividualController' => 'applications/notification/controller/PhabricatorNotificationIndividualController.php',
|
||||||
|
@ -2016,6 +2017,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorSettingsPanelSessions' => 'applications/settings/panel/PhabricatorSettingsPanelSessions.php',
|
'PhabricatorSettingsPanelSessions' => 'applications/settings/panel/PhabricatorSettingsPanelSessions.php',
|
||||||
'PhabricatorSetupCheck' => 'applications/config/check/PhabricatorSetupCheck.php',
|
'PhabricatorSetupCheck' => 'applications/config/check/PhabricatorSetupCheck.php',
|
||||||
'PhabricatorSetupCheckAPC' => 'applications/config/check/PhabricatorSetupCheckAPC.php',
|
'PhabricatorSetupCheckAPC' => 'applications/config/check/PhabricatorSetupCheckAPC.php',
|
||||||
|
'PhabricatorSetupCheckAphlict' => 'applications/notification/setup/PhabricatorSetupCheckAphlict.php',
|
||||||
'PhabricatorSetupCheckAuth' => 'applications/config/check/PhabricatorSetupCheckAuth.php',
|
'PhabricatorSetupCheckAuth' => 'applications/config/check/PhabricatorSetupCheckAuth.php',
|
||||||
'PhabricatorSetupCheckBaseURI' => 'applications/config/check/PhabricatorSetupCheckBaseURI.php',
|
'PhabricatorSetupCheckBaseURI' => 'applications/config/check/PhabricatorSetupCheckBaseURI.php',
|
||||||
'PhabricatorSetupCheckBinaries' => 'applications/config/check/PhabricatorSetupCheckBinaries.php',
|
'PhabricatorSetupCheckBinaries' => 'applications/config/check/PhabricatorSetupCheckBinaries.php',
|
||||||
|
@ -4798,6 +4800,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorSettingsPanelSearchPreferences' => 'PhabricatorSettingsPanel',
|
'PhabricatorSettingsPanelSearchPreferences' => 'PhabricatorSettingsPanel',
|
||||||
'PhabricatorSettingsPanelSessions' => 'PhabricatorSettingsPanel',
|
'PhabricatorSettingsPanelSessions' => 'PhabricatorSettingsPanel',
|
||||||
'PhabricatorSetupCheckAPC' => 'PhabricatorSetupCheck',
|
'PhabricatorSetupCheckAPC' => 'PhabricatorSetupCheck',
|
||||||
|
'PhabricatorSetupCheckAphlict' => 'PhabricatorSetupCheck',
|
||||||
'PhabricatorSetupCheckAuth' => 'PhabricatorSetupCheck',
|
'PhabricatorSetupCheckAuth' => 'PhabricatorSetupCheck',
|
||||||
'PhabricatorSetupCheckBaseURI' => 'PhabricatorSetupCheck',
|
'PhabricatorSetupCheckBaseURI' => 'PhabricatorSetupCheck',
|
||||||
'PhabricatorSetupCheckBinaries' => 'PhabricatorSetupCheck',
|
'PhabricatorSetupCheckBinaries' => 'PhabricatorSetupCheck',
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class PhabricatorNotificationClient {
|
||||||
|
|
||||||
|
const EXPECT_VERSION = 2;
|
||||||
|
|
||||||
|
public static function getServerStatus() {
|
||||||
|
$uri = PhabricatorEnv::getEnvConfig('notification.server-uri');
|
||||||
|
$uri = new PhutilURI($uri);
|
||||||
|
|
||||||
|
$uri->setPath('/status/');
|
||||||
|
|
||||||
|
list($body) = id(new HTTPSFuture($uri))
|
||||||
|
->setTimeout(3)
|
||||||
|
->resolvex();
|
||||||
|
|
||||||
|
$status = json_decode($body, true);
|
||||||
|
if (!is_array($status)) {
|
||||||
|
throw new Exception(
|
||||||
|
pht(
|
||||||
|
'Expected JSON response from notification server, received: %s',
|
||||||
|
$body));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $status;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -4,23 +4,9 @@ final class PhabricatorNotificationStatusController
|
||||||
extends PhabricatorNotificationController {
|
extends PhabricatorNotificationController {
|
||||||
|
|
||||||
public function processRequest() {
|
public function processRequest() {
|
||||||
|
|
||||||
$uri = PhabricatorEnv::getEnvConfig('notification.server-uri');
|
|
||||||
$uri = new PhutilURI($uri);
|
|
||||||
|
|
||||||
$uri->setPath('/status/');
|
|
||||||
|
|
||||||
$future = id(new HTTPSFuture($uri))
|
|
||||||
->setTimeout(3);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
list($body) = $future->resolvex();
|
$status = PhabricatorNotificationClient::getServerStatus();
|
||||||
$body = json_decode($body, true);
|
$status = $this->renderServerStatus($status);
|
||||||
if (!is_array($body)) {
|
|
||||||
throw new Exception("Expected JSON response from server!");
|
|
||||||
}
|
|
||||||
|
|
||||||
$status = $this->renderServerStatus($body);
|
|
||||||
} catch (Exception $ex) {
|
} catch (Exception $ex) {
|
||||||
$status = new AphrontErrorView();
|
$status = new AphrontErrorView();
|
||||||
$status->setTitle("Notification Server Issue");
|
$status->setTitle("Notification Server Issue");
|
||||||
|
|
|
@ -0,0 +1,64 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class PhabricatorSetupCheckAphlict extends PhabricatorSetupCheck {
|
||||||
|
|
||||||
|
protected function executeChecks() {
|
||||||
|
$enabled = PhabricatorEnv::getEnvConfig('notification.enabled');
|
||||||
|
if (!$enabled) {
|
||||||
|
// Notifications aren't set up, so just ignore all of these checks.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$status = PhabricatorNotificationClient::getServerStatus();
|
||||||
|
} catch (Exception $ex) {
|
||||||
|
$message = pht(
|
||||||
|
'Phabricator is configured to use a notification server, but '.
|
||||||
|
'is unable to connect to it. You should resolve this issue or '.
|
||||||
|
'disable the notification server. It may be helpful to double check '.
|
||||||
|
'your configuration or restart the server using the command below.'.
|
||||||
|
"\n\n".
|
||||||
|
"%s",
|
||||||
|
phutil_tag(
|
||||||
|
'pre',
|
||||||
|
array(),
|
||||||
|
array(
|
||||||
|
get_class($ex),
|
||||||
|
"\n",
|
||||||
|
$ex->getMessage(),
|
||||||
|
)));
|
||||||
|
|
||||||
|
|
||||||
|
$this->newIssue('aphlict.connect')
|
||||||
|
->setShortName(pht('Notification Server Down'))
|
||||||
|
->setName(pht('Unable to Connect to Notification Server'))
|
||||||
|
->setMessage($message)
|
||||||
|
->addRelatedPhabricatorConfig('notification.enabled')
|
||||||
|
->addRelatedPhabricatorConfig('notification.server-uri')
|
||||||
|
->addCommand(
|
||||||
|
pht(
|
||||||
|
"(To start or restart the server, run this command.)\n".
|
||||||
|
"phabricator/ $ sudo ./bin/aphlict"));
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$expect_version = PhabricatorNotificationClient::EXPECT_VERSION;
|
||||||
|
$have_version = idx($status, 'version', 1);
|
||||||
|
if ($have_version != $expect_version) {
|
||||||
|
$message = pht(
|
||||||
|
'The notification server is out of date. You are running server '.
|
||||||
|
'version %d, but Phabricator expects version %d. Restart the server '.
|
||||||
|
'to update it, using the command below:',
|
||||||
|
$have_version,
|
||||||
|
$expect_version);
|
||||||
|
|
||||||
|
$this->newIssue('aphlict.version')
|
||||||
|
->setShortName(pht('Notification Server Version'))
|
||||||
|
->setName(pht('Notification Server Out of Date'))
|
||||||
|
->setMessage($message)
|
||||||
|
->addCommand('phabricator/ $ sudo ./bin/aphlict');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -192,7 +192,8 @@ var receive_server = http.createServer(function(request, response) {
|
||||||
'clients.total': generate_id.current_id || 0,
|
'clients.total': generate_id.current_id || 0,
|
||||||
'messages.in': messages_in,
|
'messages.in': messages_in,
|
||||||
'messages.out': messages_out,
|
'messages.out': messages_out,
|
||||||
'log': config.log
|
'log': config.log,
|
||||||
|
'version': 2
|
||||||
};
|
};
|
||||||
|
|
||||||
response.write(JSON.stringify(status));
|
response.write(JSON.stringify(status));
|
||||||
|
|
|
@ -94,6 +94,7 @@
|
||||||
text-align: center;
|
text-align: center;
|
||||||
font-size: 15px;
|
font-size: 15px;
|
||||||
color: #2980b9;
|
color: #2980b9;
|
||||||
|
margin-top: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.setup-issue-config {
|
.setup-issue-config {
|
||||||
|
|
Loading…
Reference in a new issue