From 1c5bdcb6707b1938057693d993cf2baa82d5101b Mon Sep 17 00:00:00 2001 From: Peter Jaszkowiak Date: Fri, 13 Oct 2017 11:15:18 -0600 Subject: [PATCH] Enable running multiple upgrades at once (#5984) --- app.js | 9 ++++----- src/upgrade.js | 18 +++++++----------- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/app.js b/app.js index 686b355602..4ce28da224 100644 --- a/app.js +++ b/app.js @@ -219,14 +219,13 @@ function upgrade() { var meta = require('./src/meta'); var upgrade = require('./src/upgrade'); 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) { // Likely an upgrade script name passed in - tasks[2] = async.apply(upgrade.runSingle, nconf.get('upgrade')); - - // Skip build - tasks.pop(); + tasks.push(async.apply(upgrade.runParticular, nconf.get('upgrade').split(','))); + } else { + tasks.push(upgrade.run, build.buildAll); } // disable mongo timeouts during upgrade nconf.set('mongo:options:socketTimeoutMS', 0); diff --git a/src/upgrade.js b/src/upgrade.js index f1f5a016ad..97f5287bc6 100644 --- a/src/upgrade.js +++ b/src/upgrade.js @@ -87,23 +87,19 @@ Upgrade.run = function (callback) { }); }; -Upgrade.runSingle = function (query, callback) { +Upgrade.runParticular = function (names, callback) { process.stdout.write('\nParsing upgrade scripts... '); async.waterfall([ async.apply(file.walk, path.join(__dirname, './upgrades')), function (files, next) { - next(null, files.filter(function (file) { - return path.basename(file, '.js') === query; - })); - }, - ], function (err, files) { - if (err) { - return callback(err); - } + var upgrades = files.filter(function (file) { + return names.indexOf(path.basename(file, '.js')) !== -1; + }); - Upgrade.process(files, 0, callback); - }); + Upgrade.process(upgrades, 0, next); + }, + ], callback); }; Upgrade.process = function (files, skipCount, callback) {