summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn McLear <john@mclear.co.uk>2012-10-28 11:02:48 -0700
committerJohn McLear <john@mclear.co.uk>2012-10-28 11:02:48 -0700
commit05cc7b3fd5a5616fe52aed5e05efebd3ec252662 (patch)
treeae6eb628b27dc181017461b9a754ba3f55ef3fc4
parentd5ace6c163ae6ec3789027c5301ae90beeb1f229 (diff)
parent78e64ffea8b97be6a0b9267e22334713b297236a (diff)
downloadetherpad-lite-05cc7b3fd5a5616fe52aed5e05efebd3ec252662.zip
Merge pull request #1096 from marcelklehr/fix/server-startup-npm
Fix npm
-rwxr-xr-xsrc/node/server.js44
-rw-r--r--src/package.json1
-rw-r--r--src/static/js/pluginfw/installer.js9
-rw-r--r--src/static/js/pluginfw/plugins.js2
-rw-r--r--src/static/js/pluginfw/read-installed.js19
5 files changed, 55 insertions, 20 deletions
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());
diff --git a/src/package.json b/src/package.json
index e4e9b9c3..c3c4968a 100644
--- a/src/package.json
+++ b/src/package.json
@@ -27,6 +27,7 @@
"jsdom-nocontextifiy" : "0.2.10",
"async-stacktrace" : "0.0.2",
"npm" : "1.1.x",
+ "npm-registry-client" : "0.2.10",
"ejs" : "0.6.1",
"graceful-fs" : "1.1.5",
"slide" : "1.1.3",
diff --git a/src/static/js/pluginfw/installer.js b/src/static/js/pluginfw/installer.js
index e7c6fb80..d668e549 100644
--- a/src/static/js/pluginfw/installer.js
+++ b/src/static/js/pluginfw/installer.js
@@ -1,7 +1,12 @@
var plugins = require("ep_etherpad-lite/static/js/pluginfw/plugins");
var hooks = require("ep_etherpad-lite/static/js/pluginfw/hooks");
var npm = require("npm");
-var registry = require("npm/lib/utils/npm-registry-client/index.js");
+var RegClient = require("npm-registry-client")
+
+var registry = new RegClient(
+{ registry: "http://registry.npmjs.org"
+, cache: npm.cache }
+);
var withNpm = function (npmfn, final, cb) {
npm.load({}, function (er) {
@@ -72,7 +77,7 @@ exports.search = function(query, cache, cb) {
cb(null, exports.searchCache);
} else {
registry.get(
- "/-/all", null, 600, false, true,
+ "/-/all", 600, false, true,
function (er, data) {
if (er) return cb(er);
exports.searchCache = data;
diff --git a/src/static/js/pluginfw/plugins.js b/src/static/js/pluginfw/plugins.js
index 12ba94a2..e02c1331 100644
--- a/src/static/js/pluginfw/plugins.js
+++ b/src/static/js/pluginfw/plugins.js
@@ -1,7 +1,5 @@
var npm = require("npm/lib/npm.js");
var readInstalled = require("./read-installed.js");
-var relativize = require("npm/lib/utils/relativize.js");
-var readJson = require("npm/lib/utils/read-json.js");
var path = require("path");
var async = require("async");
var fs = require("fs");
diff --git a/src/static/js/pluginfw/read-installed.js b/src/static/js/pluginfw/read-installed.js
index cc03b357..800ee32c 100644
--- a/src/static/js/pluginfw/read-installed.js
+++ b/src/static/js/pluginfw/read-installed.js
@@ -94,8 +94,21 @@ var npm = require("npm/lib/npm.js")
, path = require("path")
, asyncMap = require("slide").asyncMap
, semver = require("semver")
- , readJson = require("npm/lib/utils/read-json.js")
- , log = require("npm/lib/utils/log.js")
+ , log = require("log4js").getLogger('pluginfw')
+
+function readJson(file, callback) {
+ fs.readFile(file, function(er, buf) {
+ if(er) {
+ callback(er);
+ return;
+ }
+ try {
+ callback( null, JSON.parse(buf.toString()) )
+ } catch(er) {
+ callback(er)
+ }
+ })
+}
module.exports = readInstalled
@@ -274,7 +287,7 @@ function findUnmet (obj) {
}
})
- log.verbose([obj._id], "returning")
+ log.debug([obj._id], "returning")
return obj
}