Enable running multiple upgrades at once (#5984)

v1.18.x
Peter Jaszkowiak 7 years ago committed by Julian Lam
parent bf1e922cab
commit 1c5bdcb670

@ -219,14 +219,13 @@ function upgrade() {
var meta = require('./src/meta'); var meta = require('./src/meta');
var upgrade = require('./src/upgrade'); var upgrade = require('./src/upgrade');
var build = require('./src/meta/build'); var build = require('./src/meta/build');
var tasks = [db.init, meta.configs.init, upgrade.run, build.buildAll]; var tasks = [db.init, meta.configs.init];
if (nconf.get('upgrade') !== true) { if (nconf.get('upgrade') !== true) {
// Likely an upgrade script name passed in // Likely an upgrade script name passed in
tasks[2] = async.apply(upgrade.runSingle, nconf.get('upgrade')); tasks.push(async.apply(upgrade.runParticular, nconf.get('upgrade').split(',')));
} else {
// Skip build tasks.push(upgrade.run, build.buildAll);
tasks.pop();
} }
// disable mongo timeouts during upgrade // disable mongo timeouts during upgrade
nconf.set('mongo:options:socketTimeoutMS', 0); nconf.set('mongo:options:socketTimeoutMS', 0);

@ -87,23 +87,19 @@ Upgrade.run = function (callback) {
}); });
}; };
Upgrade.runSingle = function (query, callback) { Upgrade.runParticular = function (names, callback) {
process.stdout.write('\nParsing upgrade scripts... '); process.stdout.write('\nParsing upgrade scripts... ');
async.waterfall([ async.waterfall([
async.apply(file.walk, path.join(__dirname, './upgrades')), async.apply(file.walk, path.join(__dirname, './upgrades')),
function (files, next) { function (files, next) {
next(null, files.filter(function (file) { var upgrades = files.filter(function (file) {
return path.basename(file, '.js') === query; return names.indexOf(path.basename(file, '.js')) !== -1;
})); });
},
], function (err, files) {
if (err) {
return callback(err);
}
Upgrade.process(files, 0, callback); Upgrade.process(upgrades, 0, next);
}); },
], callback);
}; };
Upgrade.process = function (files, skipCount, callback) { Upgrade.process = function (files, skipCount, callback) {

Loading…
Cancel
Save