From a8d5a60ee02c5d66655a269b1c3277bb17097915 Mon Sep 17 00:00:00 2001 From: Mark Moffat Date: Sun, 11 Feb 2018 13:02:47 +0100 Subject: [PATCH] Only running indexing on production startup --- app.js | 2 +- lib/common.js | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app.js b/app.js index d252428..6f9a47b 100644 --- a/app.js +++ b/app.js @@ -308,7 +308,7 @@ MongoClient.connect(config.databaseConnectionString, {}, (err, client) => { // add db to app for routes app.db = db; - // add indexing + // run indexing common.runIndexing(app) .then(common.testData(db, app)) .then(app.listen(app.get('port'))) diff --git a/lib/common.js b/lib/common.js index 8f896b2..a989302 100644 --- a/lib/common.js +++ b/lib/common.js @@ -582,6 +582,10 @@ exports.indexOrders = (app, cb) => { // start indexing products and orders exports.runIndexing = (app) => { + if(process.env.NODE_ENV !== 'production'){ + return Promise.resolve(); + } + console.info(colors.yellow('Setting up indexes..')); return Promise.all([