Browse files

Make previous commit more sane

  • Loading branch information...
1 parent 526e572 commit 78cd9be90ed1a8de3f58b8a8cf03bd1979ce6eb8 @smfreegard smfreegard committed Apr 16, 2012
Showing with 12 additions and 18 deletions.
  1. +7 −10 plugins.js
  2. +5 −8 server.js
View
17 plugins.js
@@ -30,7 +30,6 @@ function Plugin(name) {
this.full_paths = full_paths;
this.config = config;
this.hooks = {};
- this.server = {};
};
Plugin.prototype.register_hook = function(hook_name, method_name) {
@@ -76,16 +75,10 @@ var plugins = exports;
plugins.Plugin = Plugin;
-plugins.server = {};
-
-plugins.load_plugins = function (notes) {
+plugins.load_plugins = function () {
logger.loginfo("Loading plugins");
var plugin_list = config.get('plugins', 'list');
-
- // Add ref to server.notes here
- this.server = {};
- this.server.notes = notes;
-
+
plugins.plugin_list = plugin_list.map(plugins.load_plugin);
logger.dump_logs(); // now logging plugins are loaded.
};
@@ -101,9 +94,12 @@ plugins.load_plugin = function(name) {
return plugin;
}
+// Set in server.js; initialized to empty object
+// to prevent it from blowing up any unit tests.
+plugins.server = {};
+
plugins._load_and_compile_plugin = function(name) {
var plugin = new Plugin(name);
- plugin.server = this.server;
var fp = plugin.full_paths,
rf, last_err;
for (var i=0, j=fp.length; i<j; i++) {
@@ -136,6 +132,7 @@ plugins._load_and_compile_plugin = function(name) {
process: process,
Buffer: Buffer,
Math: Math,
+ server: plugins.server,
};
constants.import(sandbox);
try {
View
13 server.js
@@ -58,17 +58,14 @@ Server.createServer = function (params) {
// config_data defaults
apply_defaults(config_data.main);
- // Setup notes here; JavaScript passes objects by
- // ref so we can pass this up to the plugins object
- var notes = {};
-
- plugins.load_plugins(notes);
-
var server = net.createServer(function (client) {
client.setTimeout((config_data.main.inactivity_timeout || 300) * 1000);
conn.createConnection(client, server);
});
- server.notes = notes;
+ server.notes = {};
+ plugins.server = server;
+ plugins.load_plugins();
+
if (cluster && config_data.main.nodes) {
var c = cluster(server);
@@ -150,6 +147,6 @@ function listening () {
logger.lognotice("Listening on port " + config_data.main.port);
Server.ready = 1;
-
+
out.load_queue();
}

0 comments on commit 78cd9be

Please sign in to comment.