diff --git a/core/config.js b/core/config.js index b11c43e9..d8f1c873 100644 --- a/core/config.js +++ b/core/config.js @@ -100,7 +100,14 @@ function init(configPath, options, cb) { }; const ConfigCache = require('./config_cache.js'); - ConfigCache.getConfigWithOptions( { filePath : configPath, callback : changed }, (err, config) => { + const getConfigOptions = { + filePath : configPath, + noWatch : options.noWatch, + }; + if(!options.noWatch) { + getConfigOptions.callback = changed; + } + ConfigCache.getConfigWithOptions(getConfigOptions, (err, config) => { if(err) { return cb(err); } diff --git a/core/config_cache.js b/core/config_cache.js index 8ec7280c..4a1d1c5a 100644 --- a/core/config_cache.js +++ b/core/config_cache.js @@ -19,24 +19,26 @@ module.exports = new class ConfigCache if(options.forceReCache || !cached) { this.recacheConfigFromFile(options.filePath, (err, config) => { if(!err && !cached) { - const watcher = sane( - paths.dirname(options.filePath), - { - glob : `**/${paths.basename(options.filePath)}` - } - ); - - watcher.on('change', (fileName, fileRoot) => { - require('./logger.js').log.info( { fileName, fileRoot }, 'Configuration file changed; re-caching'); - - this.recacheConfigFromFile(paths.join(fileRoot, fileName), err => { - if(!err) { - if(options.callback) { - options.callback( { fileName, fileRoot } ); - } + if(!options.noWatch) { + const watcher = sane( + paths.dirname(options.filePath), + { + glob : `**/${paths.basename(options.filePath)}` } + ); + + watcher.on('change', (fileName, fileRoot) => { + require('./logger.js').log.info( { fileName, fileRoot }, 'Configuration file changed; re-caching'); + + this.recacheConfigFromFile(paths.join(fileRoot, fileName), err => { + if(!err) { + if(options.callback) { + options.callback( { fileName, fileRoot } ); + } + } + }); }); - }); + } } return cb(err, config, true); }); diff --git a/core/oputil/oputil_common.js b/core/oputil/oputil_common.js index d03bb82f..18546c98 100644 --- a/core/oputil/oputil_common.js +++ b/core/oputil/oputil_common.js @@ -2,8 +2,6 @@ /* eslint-disable no-console */ 'use strict'; -const resolvePath = require('../misc_util.js').resolvePath; - const config = require('../../core/config.js'); const db = require('../../core/database.js'); @@ -46,7 +44,7 @@ function printUsageAndSetExitCode(errMsg, exitCode) { } function getDefaultConfigPath() { - return './config/'; + return './config/'; } function getConfigPath() { @@ -57,7 +55,7 @@ function getConfigPath() { function initConfig(cb) { const configPath = getConfigPath(); - config.init(configPath, { keepWsc : true }, cb); + config.init(configPath, { keepWsc : true, noWatch : true }, cb); } function initConfigAndDatabases(cb) {