diff --git a/packages/node_modules/@node-red/registry/lib/index.js b/packages/node_modules/@node-red/registry/lib/index.js index 3632f40cf..426dfcb61 100644 --- a/packages/node_modules/@node-red/registry/lib/index.js +++ b/packages/node_modules/@node-red/registry/lib/index.js @@ -254,7 +254,8 @@ module.exports = { * Update to internal list of available modules based on what has been actually * loaded. * - * The `autoInstallModules` runtime option means the runtime may try to install + * The `externalModules.autoInstall` (previously `autoInstallModules`) + * runtime option means the runtime may try to install * missing modules after the initial load is complete. If that flag is not set * this function is used to remove the modules from the registry's saved list. * @function diff --git a/packages/node_modules/@node-red/runtime/lib/index.js b/packages/node_modules/@node-red/runtime/lib/index.js index dd1594467..2dd6db6c8 100644 --- a/packages/node_modules/@node-red/runtime/lib/index.js +++ b/packages/node_modules/@node-red/runtime/lib/index.js @@ -123,7 +123,15 @@ function start() { } log.info(os.type()+" "+os.release()+" "+os.arch()+" "+os.endianness()); return redNodes.load().then(function() { - + let autoInstallModules = false; + if (settings.hasOwnProperty('autoInstallModules')) { + log.warn(log._("runtime.deprecatedOption",{old:"autoInstallModules", new:"externalModules.autoInstall"})); + autoInstallModules = true; + } + if (settings.externalModules) { + // autoInstallModules = autoInstall enabled && (no palette setting || palette install not disabled) + autoInstallModules = settings.externalModules.autoInstall && (!settings.externalModules.palette || settings.externalModules.palette.allowInstall !== false) ; + } var i; var nodeErrors = redNodes.getNodeList(function(n) { return n.err!=null;}); var nodeMissing = redNodes.getNodeList(function(n) { return n.module && n.enabled && !n.loaded && !n.err;}); @@ -156,12 +164,12 @@ function start() { for (i in missingModules) { if (missingModules.hasOwnProperty(i)) { log.warn(" - "+i+" ("+missingModules[i].version+"): "+missingModules[i].types.join(", ")); - if (settings.autoInstallModules && i != "node-red") { + if (autoInstallModules && i != "node-red") { installingModules.push({id:i,version:missingModules[i].version}); } } } - if (!settings.autoInstallModules) { + if (!autoInstallModules) { log.info(log._("server.removing-modules")); redNodes.cleanModuleList(); } else if (installingModules.length > 0) { @@ -186,11 +194,19 @@ function start() { var reinstallAttempts = 0; var reinstallTimeout; function reinstallModules(moduleList) { - var promises = []; - var reinstallList = []; - + const promises = []; + const reinstallList = []; + const installRetry = 30000; + if (settings.hasOwnProperty('autoInstallModulesRetry')) { + log.warn(log._("runtime.deprecatedOption",{old:"autoInstallModulesRetry", new:"externalModules.autoInstallRetry"})); + installRetry = settings.autoInstallModulesRetry; + } + if (settings.externalModules && settings.externalModules.hasOwnProperty('autoInstallRetry')) { + installRetry = settings.externalModules.autoInstallRetry * 1000; + } + externalModules.autoInstallRetry for (var i=0;i { events.emit("runtime-event",{id:"node/added",retain:false,payload:m.nodes}); @@ -204,7 +220,7 @@ function reinstallModules(moduleList) { if (reinstallList.length > 0) { reinstallAttempts++; // First 5 at 1x timeout, next 5 at 2x, next 5 at 4x, then 8x - var timeout = (settings.autoInstallModulesRetry||30000) * Math.pow(2,Math.min(Math.floor(reinstallAttempts/5),3)); + var timeout = installRetry * Math.pow(2,Math.min(Math.floor(reinstallAttempts/5),3)); reinstallTimeout = setTimeout(function() { reinstallModules(reinstallList); },timeout); diff --git a/packages/node_modules/@node-red/runtime/locales/en-US/runtime.json b/packages/node_modules/@node-red/runtime/locales/en-US/runtime.json index bc866e09e..eeb4299d7 100644 --- a/packages/node_modules/@node-red/runtime/locales/en-US/runtime.json +++ b/packages/node_modules/@node-red/runtime/locales/en-US/runtime.json @@ -42,6 +42,7 @@ "uninstall-failed-long": "Uninstall of module __name__ failed:", "uninstalled": "Uninstalled module: __name__" }, + "deprecatedOption": "use of __old__ is deprecated. Use __new__ instead", "unable-to-listen": "Unable to listen on __listenpath__", "port-in-use": "Error: port in use", "uncaught-exception": "Uncaught Exception:",