1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-18 11:30:55 +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:
Joshua Spence 2014-12-30 22:06:44 +11:00
parent fcc7dbbf15
commit a00efcbfca

View file

@ -12,17 +12,6 @@ JX.require('lib/AphlictFlashPolicyServer', __dirname);
JX.require('lib/AphlictListenerList', __dirname); JX.require('lib/AphlictListenerList', __dirname);
JX.require('lib/AphlictLog', __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) { function parse_command_line_arguments(argv) {
var config = { var config = {
port: 22280, port: 22280,
@ -50,6 +39,17 @@ function parse_command_line_arguments(argv) {
return config; 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) { if (process.getuid() !== 0) {
console.log( console.log(
"ERROR: " + "ERROR: " +
@ -161,6 +161,26 @@ var messages_out = 0;
var messages_in = 0; var messages_in = 0;
var start_time = new Date().getTime(); 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) { http.createServer(function(request, response) {
// Publishing a notification. // Publishing a notification.
if (request.url == '/') { if (request.url == '/') {
@ -233,26 +253,6 @@ http.createServer(function(request, response) {
} }
}).listen(config.admin, config.host); }).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 // If we're configured to drop permissions, get rid of them now that we've
// bound to the ports we need and opened logfiles. // bound to the ports we need and opened logfiles.
if (config.user) { if (config.user) {