@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.

Every so often, ask the Aphict server how things are going

Summary: Ref T12573. This sends a "ping" to the server, and a "pong" back to the client, every 15 seconds. This tricks ELBs into thinking we're doing something useful and productive.

Test Plan: Ran `bin/aphlict debug`, loaded Phabricator, saw ping/pong in logs.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T12573

Differential Revision: https://secure.phabricator.com/D17717

+45 -10
+10 -10
resources/celerity/map.php
··· 10 10 'conpherence.pkg.css' => 'a34d59bd', 11 11 'conpherence.pkg.js' => '5f86c17d', 12 12 'core.pkg.css' => '959330a2', 13 - 'core.pkg.js' => '349e50d5', 13 + 'core.pkg.js' => '4a83713e', 14 14 'darkconsole.pkg.js' => '1f9a31bc', 15 15 'differential.pkg.css' => '90b30783', 16 16 'differential.pkg.js' => 'ddfeb49b', ··· 361 361 'rsrc/image/texture/table_header.png' => '5c433037', 362 362 'rsrc/image/texture/table_header_hover.png' => '038ec3b9', 363 363 'rsrc/image/texture/table_header_tall.png' => 'd56b434f', 364 - 'rsrc/js/application/aphlict/Aphlict.js' => '6304947a', 364 + 'rsrc/js/application/aphlict/Aphlict.js' => '674e335f', 365 365 'rsrc/js/application/aphlict/behavior-aphlict-dropdown.js' => 'caade6f2', 366 366 'rsrc/js/application/aphlict/behavior-aphlict-listen.js' => '06e7f30e', 367 367 'rsrc/js/application/aphlict/behavior-aphlict-status.js' => '5e2634b9', ··· 583 583 'herald-rule-editor' => 'd6a7e717', 584 584 'herald-test-css' => 'a52e323e', 585 585 'inline-comment-summary-css' => '51efda3a', 586 - 'javelin-aphlict' => '6304947a', 586 + 'javelin-aphlict' => '674e335f', 587 587 'javelin-behavior' => '61cbc29a', 588 588 'javelin-behavior-aphlict-dropdown' => 'caade6f2', 589 589 'javelin-behavior-aphlict-listen' => '06e7f30e', ··· 1391 1391 'javelin-install', 1392 1392 'javelin-util', 1393 1393 ), 1394 - '6304947a' => array( 1395 - 'javelin-install', 1396 - 'javelin-util', 1397 - 'javelin-websocket', 1398 - 'javelin-leader', 1399 - 'javelin-json', 1400 - ), 1401 1394 '635de1ec' => array( 1402 1395 'javelin-behavior', 1403 1396 'javelin-stratcom', 1404 1397 'javelin-workflow', 1405 1398 'javelin-dom', 1399 + ), 1400 + '674e335f' => array( 1401 + 'javelin-install', 1402 + 'javelin-util', 1403 + 'javelin-websocket', 1404 + 'javelin-leader', 1405 + 'javelin-json', 1406 1406 ), 1407 1407 '680ea2c8' => array( 1408 1408 'javelin-install',
+12
support/aphlict/server/lib/AphlictClientServer.js
··· 153 153 } 154 154 break; 155 155 156 + case 'ping': 157 + var pong = { 158 + type: 'pong' 159 + }; 160 + 161 + try { 162 + listener.writeMessage(pong); 163 + } catch (error) { 164 + // Ignore any issues here, we'll clean up elsewhere. 165 + } 166 + break; 167 + 156 168 default: 157 169 log( 158 170 'Unrecognized command "%s".',
+23
webroot/rsrc/js/application/aphlict/Aphlict.js
··· 41 41 _subscriptions: null, 42 42 _status: null, 43 43 _isReconnect: false, 44 + _keepaliveInterval: false, 44 45 45 46 start: function() { 46 47 JX.Leader.listen('onBecomeLeader', JX.bind(this, this._lead)); ··· 104 105 105 106 this._broadcastStatus('open'); 106 107 JX.Leader.broadcast(null, {type: 'aphlict.getsubscribers'}); 108 + 109 + // By default, ELBs terminate connections after 60 seconds with no 110 + // traffic. Other load balancers may have similar configuration. Send 111 + // a keepalive message every 15 seconds to prevent load balancers from 112 + // deciding they can reap this connection. 113 + 114 + var keepalive = JX.bind(this, this._keepalive); 115 + this._keepaliveInterval = setInterval(keepalive, 15000); 107 116 }, 108 117 109 118 _didReconnect: function() { ··· 124 133 }, 125 134 126 135 _close: function() { 136 + if (this._keepaliveInterval) { 137 + clearInterval(this._keepaliveInterval); 138 + this._keepaliveInterval = null; 139 + } 140 + 127 141 this._broadcastStatus('closed'); 128 142 }, 129 143 ··· 134 148 _message: function(raw) { 135 149 var message = JX.JSON.parse(raw); 136 150 var id = message.uniqueID || null; 151 + 152 + // If this is just a keepalive response, don't bother broadcasting it. 153 + if (message.type == 'pong') { 154 + return; 155 + } 137 156 138 157 JX.Leader.broadcast(id, {type: 'aphlict.server', data: message}); 139 158 }, ··· 198 217 }; 199 218 200 219 return this._write(frame); 220 + }, 221 + 222 + _keepalive: function() { 223 + this._writeCommand('ping', null); 201 224 } 202 225 203 226 },