From c2f088cb61f15ac8805988adf02cc8c6b8988e3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Wed, 23 May 2018 11:39:58 -0400 Subject: [PATCH] dont install multiple times --- install/web.js | 13 ++++++++++--- src/views/install/index.tpl | 4 ++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/install/web.js b/install/web.js index ea24d25fb2..48d2f0934f 100644 --- a/install/web.js +++ b/install/web.js @@ -25,7 +25,8 @@ winston.add(winston.transports.File, { level: 'verbose', }); -var web = {}; +var web = module.exports; + var scripts = [ 'node_modules/jquery/dist/jquery.js', 'public/vendor/xregexp/xregexp.js', @@ -34,6 +35,8 @@ var scripts = [ 'public/src/installer/install.js', ]; +var installing = false; + web.install = function (port) { port = port || 4567; winston.info('Launching web installer on port', port); @@ -107,11 +110,16 @@ function welcome(req, res) { success: !!res.locals.success, values: req.body, minimumPasswordLength: defaults.minimumPasswordLength, + installing: installing, }); } function install(req, res) { + if (installing) { + return welcome(req, res); + } req.setTimeout(0); + installing = true; var setupEnvVars = nconf.get(); for (var i in req.body) { if (req.body.hasOwnProperty(i) && !process.env.hasOwnProperty(i)) { @@ -140,6 +148,7 @@ function install(req, res) { }); child.on('close', function (data) { + installing = false; if (data === 0) { res.locals.success = true; } else { @@ -264,5 +273,3 @@ function loadDefaults(next) { next(); }); } - -module.exports = web; diff --git a/src/views/install/index.tpl b/src/views/install/index.tpl index 67cb007cad..97fa6021e3 100644 --- a/src/views/install/index.tpl +++ b/src/views/install/index.tpl @@ -8,7 +8,7 @@ - + @@ -111,7 +111,7 @@ - +