@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+100 -17
+3
src/__phutil_library_map__.php
··· 1698 1698 'PhabricatorNoteExample' => 'applications/uiexample/examples/PhabricatorNoteExample.php', 1699 1699 'PhabricatorNotificationBuilder' => 'applications/notification/builder/PhabricatorNotificationBuilder.php', 1700 1700 'PhabricatorNotificationClearController' => 'applications/notification/controller/PhabricatorNotificationClearController.php', 1701 + 'PhabricatorNotificationClient' => 'applications/notification/client/PhabricatorNotificationClient.php', 1701 1702 'PhabricatorNotificationConfigOptions' => 'applications/config/option/PhabricatorNotificationConfigOptions.php', 1702 1703 'PhabricatorNotificationController' => 'applications/notification/controller/PhabricatorNotificationController.php', 1703 1704 'PhabricatorNotificationIndividualController' => 'applications/notification/controller/PhabricatorNotificationIndividualController.php', ··· 2016 2017 'PhabricatorSettingsPanelSessions' => 'applications/settings/panel/PhabricatorSettingsPanelSessions.php', 2017 2018 'PhabricatorSetupCheck' => 'applications/config/check/PhabricatorSetupCheck.php', 2018 2019 'PhabricatorSetupCheckAPC' => 'applications/config/check/PhabricatorSetupCheckAPC.php', 2020 + 'PhabricatorSetupCheckAphlict' => 'applications/notification/setup/PhabricatorSetupCheckAphlict.php', 2019 2021 'PhabricatorSetupCheckAuth' => 'applications/config/check/PhabricatorSetupCheckAuth.php', 2020 2022 'PhabricatorSetupCheckBaseURI' => 'applications/config/check/PhabricatorSetupCheckBaseURI.php', 2021 2023 'PhabricatorSetupCheckBinaries' => 'applications/config/check/PhabricatorSetupCheckBinaries.php', ··· 4798 4800 'PhabricatorSettingsPanelSearchPreferences' => 'PhabricatorSettingsPanel', 4799 4801 'PhabricatorSettingsPanelSessions' => 'PhabricatorSettingsPanel', 4800 4802 'PhabricatorSetupCheckAPC' => 'PhabricatorSetupCheck', 4803 + 'PhabricatorSetupCheckAphlict' => 'PhabricatorSetupCheck', 4801 4804 'PhabricatorSetupCheckAuth' => 'PhabricatorSetupCheck', 4802 4805 'PhabricatorSetupCheckBaseURI' => 'PhabricatorSetupCheck', 4803 4806 'PhabricatorSetupCheckBinaries' => 'PhabricatorSetupCheck',
+28
src/applications/notification/client/PhabricatorNotificationClient.php
··· 1 + <?php 2 + 3 + final class PhabricatorNotificationClient { 4 + 5 + const EXPECT_VERSION = 2; 6 + 7 + public static function getServerStatus() { 8 + $uri = PhabricatorEnv::getEnvConfig('notification.server-uri'); 9 + $uri = new PhutilURI($uri); 10 + 11 + $uri->setPath('/status/'); 12 + 13 + list($body) = id(new HTTPSFuture($uri)) 14 + ->setTimeout(3) 15 + ->resolvex(); 16 + 17 + $status = json_decode($body, true); 18 + if (!is_array($status)) { 19 + throw new Exception( 20 + pht( 21 + 'Expected JSON response from notification server, received: %s', 22 + $body)); 23 + } 24 + 25 + return $status; 26 + } 27 + 28 + }
+2 -16
src/applications/notification/controller/PhabricatorNotificationStatusController.php
··· 4 4 extends PhabricatorNotificationController { 5 5 6 6 public function processRequest() { 7 - 8 - $uri = PhabricatorEnv::getEnvConfig('notification.server-uri'); 9 - $uri = new PhutilURI($uri); 10 - 11 - $uri->setPath('/status/'); 12 - 13 - $future = id(new HTTPSFuture($uri)) 14 - ->setTimeout(3); 15 - 16 7 try { 17 - list($body) = $future->resolvex(); 18 - $body = json_decode($body, true); 19 - if (!is_array($body)) { 20 - throw new Exception("Expected JSON response from server!"); 21 - } 22 - 23 - $status = $this->renderServerStatus($body); 8 + $status = PhabricatorNotificationClient::getServerStatus(); 9 + $status = $this->renderServerStatus($status); 24 10 } catch (Exception $ex) { 25 11 $status = new AphrontErrorView(); 26 12 $status->setTitle("Notification Server Issue");
+64
src/applications/notification/setup/PhabricatorSetupCheckAphlict.php
··· 1 + <?php 2 + 3 + final class PhabricatorSetupCheckAphlict extends PhabricatorSetupCheck { 4 + 5 + protected function executeChecks() { 6 + $enabled = PhabricatorEnv::getEnvConfig('notification.enabled'); 7 + if (!$enabled) { 8 + // Notifications aren't set up, so just ignore all of these checks. 9 + return; 10 + } 11 + 12 + try { 13 + $status = PhabricatorNotificationClient::getServerStatus(); 14 + } catch (Exception $ex) { 15 + $message = pht( 16 + 'Phabricator is configured to use a notification server, but '. 17 + 'is unable to connect to it. You should resolve this issue or '. 18 + 'disable the notification server. It may be helpful to double check '. 19 + 'your configuration or restart the server using the command below.'. 20 + "\n\n". 21 + "%s", 22 + phutil_tag( 23 + 'pre', 24 + array(), 25 + array( 26 + get_class($ex), 27 + "\n", 28 + $ex->getMessage(), 29 + ))); 30 + 31 + 32 + $this->newIssue('aphlict.connect') 33 + ->setShortName(pht('Notification Server Down')) 34 + ->setName(pht('Unable to Connect to Notification Server')) 35 + ->setMessage($message) 36 + ->addRelatedPhabricatorConfig('notification.enabled') 37 + ->addRelatedPhabricatorConfig('notification.server-uri') 38 + ->addCommand( 39 + pht( 40 + "(To start or restart the server, run this command.)\n". 41 + "phabricator/ $ sudo ./bin/aphlict")); 42 + 43 + return; 44 + } 45 + 46 + $expect_version = PhabricatorNotificationClient::EXPECT_VERSION; 47 + $have_version = idx($status, 'version', 1); 48 + if ($have_version != $expect_version) { 49 + $message = pht( 50 + 'The notification server is out of date. You are running server '. 51 + 'version %d, but Phabricator expects version %d. Restart the server '. 52 + 'to update it, using the command below:', 53 + $have_version, 54 + $expect_version); 55 + 56 + $this->newIssue('aphlict.version') 57 + ->setShortName(pht('Notification Server Version')) 58 + ->setName(pht('Notification Server Out of Date')) 59 + ->setMessage($message) 60 + ->addCommand('phabricator/ $ sudo ./bin/aphlict'); 61 + } 62 + 63 + } 64 + }
+2 -1
support/aphlict/server/aphlict_server.js
··· 192 192 'clients.total': generate_id.current_id || 0, 193 193 'messages.in': messages_in, 194 194 'messages.out': messages_out, 195 - 'log': config.log 195 + 'log': config.log, 196 + 'version': 2 196 197 }; 197 198 198 199 response.write(JSON.stringify(status));
+1
webroot/rsrc/css/application/config/setup-issue.css
··· 94 94 text-align: center; 95 95 font-size: 15px; 96 96 color: #2980b9; 97 + margin-top: 12px; 97 98 } 98 99 99 100 .setup-issue-config {