1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 06:42:42 +01:00

Improve debug support for notifications

Summary: Add a `notification.debug` setting that shows debug info in the browser. Also improve some logging/error handling stuff and fix a bug with host names.

Test Plan: {F13098}

Reviewers: jungejason, btrahan, vrana

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T944

Differential Revision: https://secure.phabricator.com/D2810
This commit is contained in:
epriestley 2012-06-20 13:20:47 -07:00
parent addc2c8764
commit 5e184ee593
8 changed files with 61 additions and 128 deletions

View file

@ -209,6 +209,9 @@ return array(
// PID file to use.
'notification.pidfile' => '/var/run/aphlict.pid',
// Enable this option to get additional debug output in the browser.
'notification.debug' => false,
// -- Email ----------------------------------------------------------------- //

View file

@ -49,20 +49,6 @@ celerity_register_resource_map(array(
'disk' => '/rsrc/image/custom/example_template.png',
'type' => 'png',
),
'/rsrc/image/facebook/icon/fatcow/speedometer.png' =>
array(
'hash' => '3345a7ba5b3c99dbfa3a922a16756815',
'uri' => '/res/3345a7ba/rsrc/image/facebook/icon/fatcow/speedometer.png',
'disk' => '/rsrc/image/facebook/icon/fatcow/speedometer.png',
'type' => 'png',
),
'/rsrc/image/facebook/icon/sandcastle.png' =>
array(
'hash' => '496a1c2e91ccb8332435491a7bbfa67d',
'uri' => '/res/496a1c2e/rsrc/image/facebook/icon/sandcastle.png',
'disk' => '/rsrc/image/facebook/icon/sandcastle.png',
'type' => 'png',
),
'/rsrc/image/grippy_texture.png' =>
array(
'hash' => 'a8945e12ceeaddd5b491a8d81cfa19c1',
@ -701,69 +687,6 @@ celerity_register_resource_map(array(
),
'disk' => '/rsrc/css/application/diffusion/diffusion-source.css',
),
'facebook-differential-core-view-css' =>
array(
'uri' => '/res/6053fa4a/rsrc/css/facebook/application/differential/core.css',
'type' => 'css',
'requires' =>
array(
),
'disk' => '/rsrc/css/facebook/application/differential/core.css',
),
'facebook-example-css' =>
array(
'uri' => '/res/6ba49cd8/rsrc/css/facebook/application/example/example.css',
'type' => 'css',
'requires' =>
array(
),
'disk' => '/rsrc/css/facebook/application/example/example.css',
),
'facebook-example-js' =>
array(
'uri' => '/res/31058d06/rsrc/js/facebook/application/example/example.js',
'type' => 'js',
'requires' =>
array(
),
'disk' => '/rsrc/js/facebook/application/example/example.js',
),
'facebook-releeph-branch' =>
array(
'uri' => '/res/6b7eea98/rsrc/css/facebook/application/releeph/releeph-branch.css',
'type' => 'css',
'requires' =>
array(
),
'disk' => '/rsrc/css/facebook/application/releeph/releeph-branch.css',
),
'facebook-releeph-core' =>
array(
'uri' => '/res/c3027f71/rsrc/css/facebook/application/releeph/releeph-core.css',
'type' => 'css',
'requires' =>
array(
),
'disk' => '/rsrc/css/facebook/application/releeph/releeph-core.css',
),
'facebook-releeph-project' =>
array(
'uri' => '/res/497c0c11/rsrc/css/facebook/application/releeph/releeph-project.css',
'type' => 'css',
'requires' =>
array(
),
'disk' => '/rsrc/css/facebook/application/releeph/releeph-project.css',
),
'facebook-releeph-request-typeahead-css' =>
array(
'uri' => '/res/2f4bab97/rsrc/css/facebook/application/releeph/request-typeahead.css',
'type' => 'css',
'requires' =>
array(
),
'disk' => '/rsrc/css/facebook/application/releeph/request-typeahead.css',
),
'files-css' =>
array(
'uri' => '/res/a265a77d/rsrc/css/application/files/files.css',
@ -856,7 +779,7 @@ celerity_register_resource_map(array(
),
'javelin-behavior-aphlict-listen' =>
array(
'uri' => '/res/da96a861/rsrc/js/application/aphlict/behavior-aphlict-listen.js',
'uri' => '/res/c716b386/rsrc/js/application/aphlict/behavior-aphlict-listen.js',
'type' => 'js',
'requires' =>
array(
@ -866,7 +789,8 @@ celerity_register_resource_map(array(
3 => 'javelin-request',
4 => 'javelin-uri',
5 => 'javelin-dom',
6 => 'phabricator-notification',
6 => 'javelin-json',
7 => 'phabricator-notification',
),
'disk' => '/rsrc/js/application/aphlict/behavior-aphlict-listen.js',
),
@ -1239,25 +1163,6 @@ celerity_register_resource_map(array(
),
'disk' => '/rsrc/js/application/core/behavior-error-log.js',
),
'javelin-behavior-facebook-releeph-request-typeahead' =>
array(
'uri' => '/res/585eff76/rsrc/js/facebook/application/releeph/request-typeahead.js',
'type' => 'js',
'requires' =>
array(
0 => 'javelin-behavior',
1 => 'javelin-util',
2 => 'javelin-dom',
3 => 'javelin-typeahead',
4 => 'javelin-tokenizer',
5 => 'javelin-typeahead-preloaded-source',
6 => 'javelin-typeahead-ondemand-source',
7 => 'javelin-dom',
8 => 'javelin-stratcom',
9 => 'javelin-util',
),
'disk' => '/rsrc/js/facebook/application/releeph/request-typeahead.js',
),
'javelin-behavior-fancy-datepicker' =>
array(
'uri' => '/res/b2d89e4c/rsrc/js/application/core/behavior-fancy-datepicker.js',
@ -2292,7 +2197,7 @@ celerity_register_resource_map(array(
),
'phabricator-notification-css' =>
array(
'uri' => '/res/7452322a/rsrc/css/aphront/notification.css',
'uri' => '/res/1ed48691/rsrc/css/aphront/notification.css',
'type' => 'css',
'requires' =>
array(

View file

@ -76,7 +76,8 @@ You can run `aphlict` in the foreground to get output to your console:
phabricator/ $ ./bin/aphlict --foreground
This may help identify and resolve problems.
You can set `notification.debug` in your configuration to get additional
output in your browser.
The server also generates a log, by default in `/var/log/aphlict.log`. You can
change this location by changing `notification.log` in your configuration. The

View file

@ -394,16 +394,20 @@ final class PhabricatorStandardPageView extends AphrontPageView {
$client_uri = PhabricatorEnv::getEnvConfig('notification.client-uri');
$client_uri = new PhutilURI($client_uri);
if ($client_uri->getDomain() == 'localhost') {
$this_host = new PhutilURI($this->getRequest()->getHost());
$this_host = $this->getRequest()->getHost();
$this_host = new PhutilURI('http://'.$this_host.'/');
$client_uri->setDomain($this_host->getDomain());
}
$enable_debug = PhabricatorEnv::getEnvConfig('notification.debug');
Javelin::initBehavior(
'aphlict-listen',
array(
'id' => $aphlict_object_id,
'server' => $client_uri->getDomain(),
'port' => $client_uri->getPort(),
'debug' => $enable_debug,
'pageObjects' => array_fill_keys($this->pageObjects, true),
));

View file

@ -37,7 +37,6 @@ package {
this.remotePort = port;
this.connectToServer();
return;
}

View file

@ -51,17 +51,25 @@ var querystring = require('querystring');
var fs = require('fs');
// set up log file
var logfile = fs.createWriteStream(config.log,
{ flags: 'a',
var logfile = fs.createWriteStream(
config.log,
{
flags: 'a',
encoding: null,
mode: 0666 });
logfile.write('----- ' + (new Date()).toLocaleString() + ' -----\n');
mode: 0666
});
function log(str) {
console.log(str);
logfile.write(str + '\n');
}
process.on('uncaughtException', function (err) {
log("\n<<< UNCAUGHT EXCEPTION! >>>\n\n" + err);
process.exit(1);
});
log('----- ' + (new Date()).toLocaleString() + ' -----\n');
function getFlashPolicy() {
return [
@ -75,9 +83,10 @@ function getFlashPolicy() {
}
net.createServer(function(socket) {
socket.on('data', function() {
socket.write(getFlashPolicy() + '\0');
});
socket.end();
log('[' + socket.remoteAddress + '] Sent Flash Policy');
socket.on('error', function (e) {
log('Error in policy server: ' + e);
@ -85,7 +94,6 @@ net.createServer(function(socket) {
}).listen(843);
function write_json(socket, data) {
var serial = JSON.stringify(data);
var length = Buffer.byteLength(serial, 'utf8');
@ -118,32 +126,33 @@ function generate_id() {
var send_server = net.createServer(function(socket) {
var client_id = generate_id();
var client_name = '[' + socket.remoteAddress + '] [#' + client_id + '] ';
socket.on('connect', function() {
clients[client_id] = socket;
current_connections++;
log(client_id + ': connected\t\t('
log(client_name + 'connected\t\t('
+ current_connections + ' current connections)');
});
socket.on('close', function() {
delete clients[client_id];
current_connections--;
log(client_id + ': closed\t\t('
log(client_name + 'closed\t\t('
+ current_connections + ' current connections)');
});
socket.on('timeout', function() {
log(client_id + ': timed out!');
log(client_name + 'timed out!');
});
socket.on('end', function() {
log(client_id + ': ended the connection');
log(client_name + 'ended the connection');
// node automatically closes half-open connections
});
socket.on('error', function (e) {
log('Uncaught error in send server: ' + e);
log(cliient_name + 'Uncaught error in send server: ' + e);
});
}).listen(config.port);

View file

@ -31,3 +31,8 @@
background: #ffffa0;
border: 1px solid #aaaa60;
}
.jx-notification-debug {
background: #ffa0ff;
border: 1px solid #aa60aa;
}

View file

@ -6,6 +6,7 @@
* javelin-request
* javelin-uri
* javelin-dom
* javelin-json
* phabricator-notification
*/
@ -23,17 +24,23 @@ JX.behavior('aphlict-listen', function(config) {
// Respond to a notification from the Aphlict notification server. We send
// a request to Phabricator to get notification details.
function onaphlictmessage(type, message) {
if (!message) {
return;
}
if (type != 'receive') {
return;
}
if (type == 'receive') {
var request = new JX.Request('/notification/individual/', onnotification)
.addData({key: message.key})
.send();
} else if (__DEV__) {
if (config.debug) {
var details = message
? JX.JSON.stringify(message)
: '';
new JX.Notification()
.setContent('(Aphlict) [' + type + '] ' + details)
.setClassName('jx-notification-debug')
.setDuration(0)
.show();
}
}
}