diff --git a/core/config.js b/core/config.js index 791845b8..788514ae 100644 --- a/core/config.js +++ b/core/config.js @@ -12,7 +12,12 @@ exports.Config = class Config extends ConfigLoader { super(options); } - static create(baseConfigPath, cb) { + static create(baseConfigPath, options, cb) { + if (!cb && _.isFunction(options)) { + cb = options; + options = {}; + } + const replacePaths = [ 'loginServers.ssh.algorithms.kex', 'loginServers.ssh.algorithms.cipher', @@ -24,7 +29,7 @@ exports.Config = class Config extends ConfigLoader { 'args', 'sendArgs', 'recvArgs', 'recvArgsNonBatch', ]; - const options = { + const configOptions = Object.assign({}, options, { defaultConfig : DefaultConfig, defaultsCustomizer : (defaultVal, configVal, key, path) => { if (Array.isArray(defaultVal) && Array.isArray(configVal)) { @@ -43,9 +48,9 @@ exports.Config = class Config extends ConfigLoader { Events.emit(Events.getSystemEvents().ConfigChanged); } }, - }; + }); - systemConfigInstance = new Config(options); + systemConfigInstance = new Config(configOptions); systemConfigInstance.init(baseConfigPath, err => { if (err) { console.stdout(`Configuration ${baseConfigPath} error: ${err.message}`); // eslint-disable-line no-console diff --git a/core/config_loader.js b/core/config_loader.js index 768cbe1d..29c2ab58 100644 --- a/core/config_loader.js +++ b/core/config_loader.js @@ -13,12 +13,14 @@ module.exports = class ConfigLoader { defaultConfig = {}, defaultsCustomizer = null, onReload = null, + keepWsc = false, } = { hotReload : true, defaultConfig : {}, defaultsCustomizer : null, onReload : null, + keepWsc : false, } ) { @@ -28,6 +30,7 @@ module.exports = class ConfigLoader { this.defaultConfig = defaultConfig; this.defaultsCustomizer = defaultsCustomizer; this.onReload = onReload; + this.keepWsc = keepWsc; } init(baseConfigPath, cb) { @@ -176,6 +179,7 @@ module.exports = class ConfigLoader { const options = { filePath, hotReload : this.hotReload, + keepWsc : this.keepWsc, callback : this._configFileChanged.bind(this), }; diff --git a/core/oputil/oputil_common.js b/core/oputil/oputil_common.js index ff6e348b..72b6f14b 100644 --- a/core/oputil/oputil_common.js +++ b/core/oputil/oputil_common.js @@ -71,7 +71,7 @@ function getConfigPath() { function initConfig(cb) { const configPath = getConfigPath(); - config.init(configPath, { keepWsc : true, hotReload : false }, cb); + config.Config.create(configPath, { keepWsc : true, hotReload : false }, cb); } function initConfigAndDatabases(cb) {