mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Pass full runtime object to storage and flow sub-components
This commit is contained in:
@@ -83,7 +83,7 @@ function start() {
|
||||
.then(function() {
|
||||
return i18n.registerMessageCatalog("runtime",path.resolve(path.join(__dirname,"locales")),"runtime.json")
|
||||
})
|
||||
.then(function() { return storage.init(settings)})
|
||||
.then(function() { return storage.init(runtime)})
|
||||
.then(function() { return settings.load(storage)})
|
||||
.then(function() {
|
||||
|
||||
|
@@ -43,12 +43,12 @@ var subflowInstanceNodeMap = {};
|
||||
|
||||
var typeEventRegistered = false;
|
||||
|
||||
function init(_settings, _storage) {
|
||||
function init(runtime) {
|
||||
if (started) {
|
||||
throw new Error("Cannot init without a stop");
|
||||
}
|
||||
settings = _settings;
|
||||
storage = _storage;
|
||||
settings = runtime.settings;
|
||||
storage = runtime.storage;
|
||||
started = false;
|
||||
if (!typeEventRegistered) {
|
||||
events.on('type-registered',function(type) {
|
||||
|
@@ -78,7 +78,7 @@ function createNode(node,def) {
|
||||
function init(runtime) {
|
||||
settings = runtime.settings;
|
||||
credentials.init(runtime.storage);
|
||||
flows.init(runtime.settings,runtime.storage);
|
||||
flows.init(runtime);
|
||||
registry.init(runtime);
|
||||
context.init(runtime.settings);
|
||||
}
|
||||
|
@@ -18,6 +18,7 @@ var when = require('when');
|
||||
var Path = require('path');
|
||||
var log = require("../log");
|
||||
|
||||
var runtime;
|
||||
var storageModule;
|
||||
var settingsAvailable;
|
||||
var sessionsAvailable;
|
||||
@@ -42,15 +43,16 @@ function is_malicious(path) {
|
||||
}
|
||||
|
||||
var storageModuleInterface = {
|
||||
init: function(settings) {
|
||||
init: function(_runtime) {
|
||||
runtime = _runtime;
|
||||
try {
|
||||
storageModule = moduleSelector(settings);
|
||||
storageModule = moduleSelector(runtime.settings);
|
||||
settingsAvailable = storageModule.hasOwnProperty("getSettings") && storageModule.hasOwnProperty("saveSettings");
|
||||
sessionsAvailable = storageModule.hasOwnProperty("getSessions") && storageModule.hasOwnProperty("saveSessions");
|
||||
} catch (e) {
|
||||
return when.reject(e);
|
||||
}
|
||||
return storageModule.init(settings);
|
||||
return storageModule.init(runtime.settings);
|
||||
},
|
||||
getFlows: function() {
|
||||
return storageModule.getFlows();
|
||||
|
Reference in New Issue
Block a user