dont install multiple times

v1.18.x
Barış Soner Uşaklı 7 years ago
parent d856c1af86
commit c2f088cb61

@ -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;

@ -111,7 +111,7 @@
</div>
<!-- ENDIF !skipDatabaseSetup -->
<button id="submit" type="submit" class="btn btn-lg btn-success">Install NodeBB <i class="working hide"></i></button>
<button id="submit" type="submit" class="btn btn-lg btn-success" <!-- IF installing -->disabled<!-- ENDIF installing -->>Install NodeBB <i class="working hide"></i></button>
</form>
</div>

Loading…
Cancel
Save