From a00efcbfca023d564f01b365753bbf26f5c3deae Mon Sep 17 00:00:00 2001 From: Joshua Spence Date: Tue, 30 Dec 2014 22:06:44 +1100 Subject: [PATCH] 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 --- support/aphlict/server/aphlict_server.js | 62 ++++++++++++------------ 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/support/aphlict/server/aphlict_server.js b/support/aphlict/server/aphlict_server.js index ef85c6fcfe..82cec664a2 100644 --- a/support/aphlict/server/aphlict_server.js +++ b/support/aphlict/server/aphlict_server.js @@ -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) {