From e447a6fade15ed2df53fef3e5845c134232306b8 Mon Sep 17 00:00:00 2001 From: Marcel Klehr Date: Sun, 28 Oct 2012 18:02:49 +0100 Subject: Make sure npm is initialized before requiring things (fix #1092) --- src/node/server.js | 44 +++++++++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 13 deletions(-) (limited to 'src/node') diff --git a/src/node/server.js b/src/node/server.js index b91b0e17..327fa166 100755 --- a/src/node/server.js +++ b/src/node/server.js @@ -21,31 +21,49 @@ * limitations under the License. */ +var log4js = require('log4js') + , async = require('async') + ; + // set up logger -var log4js = require('log4js'); log4js.replaceConsole(); -var settings = require('./utils/Settings'); - -//set loglevel -log4js.setGlobalLogLevel(settings.loglevel); - -var db = require('./db/DB'); -var async = require('async'); -var plugins = require("ep_etherpad-lite/static/js/pluginfw/plugins"); -var hooks = require("ep_etherpad-lite/static/js/pluginfw/hooks"); +var settings + , db + , plugins + , hooks; var npm = require("npm/lib/npm.js"); -hooks.plugins = plugins; - async.waterfall([ + // load npm + function(callback) { + npm.load({}, function(er) { + callback(er) + }) + }, + + // load everything + function(callback) { + settings = require('./utils/Settings'); + db = require('./db/DB'); + plugins = require("ep_etherpad-lite/static/js/pluginfw/plugins"); + hooks = require("ep_etherpad-lite/static/js/pluginfw/hooks"); + hooks.plugins = plugins; + + //set loglevel + log4js.setGlobalLogLevel(settings.loglevel); + callback(); + }, + //initalize the database function (callback) { db.init(callback); }, - plugins.update, + function(callback) { + plugins.update(callback) + }, function (callback) { console.info("Installed plugins: " + plugins.formatPlugins()); -- cgit v1.2.3