mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-17 20:32:41 +01:00
Fix some functions being used before they are defined
Summary: Minor JSHint fixes. Test Plan: `arc lint` Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: Korvin, epriestley Differential Revision: https://secure.phabricator.com/D11073
This commit is contained in:
parent
fcc7dbbf15
commit
a00efcbfca
1 changed files with 31 additions and 31 deletions
|
@ -12,17 +12,6 @@ JX.require('lib/AphlictFlashPolicyServer', __dirname);
|
|||
JX.require('lib/AphlictListenerList', __dirname);
|
||||
JX.require('lib/AphlictLog', __dirname);
|
||||
|
||||
var debug = new JX.AphlictLog()
|
||||
.addConsole(console);
|
||||
|
||||
var clients = new JX.AphlictListenerList();
|
||||
|
||||
var config = parse_command_line_arguments(process.argv);
|
||||
|
||||
if (config.logfile) {
|
||||
debug.addLogfile(config.logfile);
|
||||
}
|
||||
|
||||
function parse_command_line_arguments(argv) {
|
||||
var config = {
|
||||
port: 22280,
|
||||
|
@ -50,6 +39,17 @@ function parse_command_line_arguments(argv) {
|
|||
return config;
|
||||
}
|
||||
|
||||
var debug = new JX.AphlictLog()
|
||||
.addConsole(console);
|
||||
|
||||
var clients = new JX.AphlictListenerList();
|
||||
|
||||
var config = parse_command_line_arguments(process.argv);
|
||||
|
||||
if (config.logfile) {
|
||||
debug.addLogfile(config.logfile);
|
||||
}
|
||||
|
||||
if (process.getuid() !== 0) {
|
||||
console.log(
|
||||
"ERROR: " +
|
||||
|
@ -161,6 +161,26 @@ var messages_out = 0;
|
|||
var messages_in = 0;
|
||||
var start_time = new Date().getTime();
|
||||
|
||||
function transmit(msg) {
|
||||
var listeners = clients.getListeners().filter(function(client) {
|
||||
return client.isSubscribedToAny(msg.subscribers);
|
||||
});
|
||||
|
||||
for (var i = 0; i < listeners.length; i++) {
|
||||
var listener = listeners[i];
|
||||
|
||||
try {
|
||||
listener.writeMessage(msg);
|
||||
|
||||
++messages_out;
|
||||
debug.log('<%s> Wrote Message', listener.getDescription());
|
||||
} catch (error) {
|
||||
clients.removeListener(listener);
|
||||
debug.log('<%s> Write Error: %s', listener.getDescription(), error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
http.createServer(function(request, response) {
|
||||
// Publishing a notification.
|
||||
if (request.url == '/') {
|
||||
|
@ -233,26 +253,6 @@ http.createServer(function(request, response) {
|
|||
}
|
||||
}).listen(config.admin, config.host);
|
||||
|
||||
function transmit(msg) {
|
||||
var listeners = clients.getListeners().filter(function(client) {
|
||||
return client.isSubscribedToAny(msg.subscribers);
|
||||
});
|
||||
|
||||
for (var i = 0; i < listeners.length; i++) {
|
||||
var listener = listeners[i];
|
||||
|
||||
try {
|
||||
listener.writeMessage(msg);
|
||||
|
||||
++messages_out;
|
||||
debug.log('<%s> Wrote Message', listener.getDescription());
|
||||
} catch (error) {
|
||||
clients.removeListener(listener);
|
||||
debug.log('<%s> Write Error: %s', listener.getDescription(), error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If we're configured to drop permissions, get rid of them now that we've
|
||||
// bound to the ports we need and opened logfiles.
|
||||
if (config.user) {
|
||||
|
|
Loading…
Reference in a new issue