diff --git a/red/runtime/index.js b/red/runtime/index.js index e8af69712..19e3dc17e 100644 --- a/red/runtime/index.js +++ b/red/runtime/index.js @@ -90,7 +90,6 @@ function start() { }) .then(function() { return storage.init(runtime)}) .then(function() { return settings.load(storage)}) - .then(function() { return redNodes.loadContextsPlugin()}) .then(function() { if (log.metric()) { @@ -163,8 +162,10 @@ function start() { if (settings.httpStatic) { log.info(log._("runtime.paths.httpStatic",{path:path.resolve(settings.httpStatic)})); } - redNodes.loadFlows().then(redNodes.startFlows).catch(function(err) {}); - started = true; + redNodes.loadContextsPlugin().then(function () { + redNodes.loadFlows().then(redNodes.startFlows).catch(function(err) {}); + started = true; + }); }).catch(function(err) { console.log(err); }); diff --git a/red/runtime/locales/en-US/runtime.json b/red/runtime/locales/en-US/runtime.json index c0fac42dc..36a3ef314 100644 --- a/red/runtime/locales/en-US/runtime.json +++ b/red/runtime/locales/en-US/runtime.json @@ -163,7 +163,9 @@ "error-module-not-defined": "'module' is not defined in '__storage__' of settings.contextStorage", "error-invalid-module-name": "Invalid context store name: '__name__'", "error-invalid-default-module": "Invalid storage '__storage__' is specified as a default storage", - "error-use-undefined-storage": "Undefined storage '__storage__' is specified" + "error-use-undefined-storage": "Undefined storage '__storage__' is specified", + "unknown-store": "Unknown store '__name__' specified. Use default store instead.", + "log-store-init": "Context store : '__name__' [__info__]" } } diff --git a/red/runtime/nodes/context/index.js b/red/runtime/nodes/context/index.js index a12943863..cb61ca187 100644 --- a/red/runtime/nodes/context/index.js +++ b/red/runtime/nodes/context/index.js @@ -31,6 +31,26 @@ var defaultStore; // Whether there context storage has been configured or left as default var hasConfiguredStore = false; +// Unknown Stores +var unknownStores = {}; + +function logUnknownStore(name) { + if (name) { + var count = unknownStores[name] || 0; + if (count == 0) { + log.warn(log._("context.unknown-store", {name: name})); + count++; + unknownStores[name] = count; + } + } +} + +function logStore(name, module) { + if (name !== '_') { // ignore default store + log.info(log._("context.log-store-init", + {name:name, info:"module="+module})); + } +} function init(_settings) { settings = _settings; @@ -93,6 +113,7 @@ function load() { try { // Create a new instance of the plugin by calling its module function stores[pluginName] = plugin(config); + logStore(pluginName, plugins[pluginName].module); } catch(err) { return reject(new Error(log._("context.error-loading-module",{module:pluginName,message:err.toString()}))); } @@ -158,6 +179,7 @@ function getContextStorage(storage) { return stores[storage]; } else if (stores.hasOwnProperty("_")) { // Not known, but we have a default to fall back to + logUnknownStore(storage); return stores["_"]; } else { // Not known and no default configured diff --git a/red/runtime/nodes/context/memory.js b/red/runtime/nodes/context/memory.js index 3e333724e..1f76a1520 100644 --- a/red/runtime/nodes/context/memory.js +++ b/red/runtime/nodes/context/memory.js @@ -124,7 +124,6 @@ Memory.prototype._export = function() { return this.data; } - module.exports = function(config){ return new Memory(config); }; diff --git a/test/red/runtime/nodes/context/index_spec.js b/test/red/runtime/nodes/context/index_spec.js index 46a973001..693b9be16 100644 --- a/test/red/runtime/nodes/context/index_spec.js +++ b/test/red/runtime/nodes/context/index_spec.js @@ -901,4 +901,5 @@ describe('context', function() { }); }); }); + }); diff --git a/test/red/runtime/nodes/context/localfilesystem_spec.js b/test/red/runtime/nodes/context/localfilesystem_spec.js index 267ef3dd9..f461dace6 100644 --- a/test/red/runtime/nodes/context/localfilesystem_spec.js +++ b/test/red/runtime/nodes/context/localfilesystem_spec.js @@ -478,7 +478,7 @@ describe('localfilesystem',function() { }); }); - describe('if cache is enabled',function() { + describe('#if cache is enabled',function() { afterEach(function() { return context.clean([]).then(function(){ return context.close().then(function(){