From 29b0552466d223252781adeb50bfb06bb96c2ac1 Mon Sep 17 00:00:00 2001 From: barisusakli Date: Thu, 26 Jan 2017 14:16:19 +0300 Subject: [PATCH] update url from config file even if it was passed in env --- loader.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/loader.js b/loader.js index df528871e9..fa8945e48c 100644 --- a/loader.js +++ b/loader.js @@ -151,9 +151,25 @@ function getPorts() { Loader.restart = function () { killWorkers(); + + var pathToConfig = path.join(__dirname, '/config.json'); nconf.remove('file'); - nconf.use('file', { file: path.join(__dirname, '/config.json') }); - Loader.start(); + nconf.use('file', { file: pathToConfig }); + + fs.readFile(pathToConfig, {encoding: 'utf-8'}, function(err, configFile) { + if (err) { + console.log('Error reading config : ' + err.message); + process.exit(); + } + + var conf = JSON.parse(configFile); + + nconf.stores.env.readOnly = false; + nconf.set('url', conf.url); + nconf.stores.env.readOnly = true; + + Loader.start(); + }); }; Loader.reload = function () {