From d72493364057c00bce2fe82afc5d002a51f2fbc3 Mon Sep 17 00:00:00 2001 From: Matteo Pagliazzi Date: Wed, 18 Mar 2020 19:17:08 +0100 Subject: [PATCH] update mongoose options --- config.json.example | 4 ++-- website/server/libs/setupMongoose.js | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/config.json.example b/config.json.example index 32ba8cf1a1..306e1bb24e 100644 --- a/config.json.example +++ b/config.json.example @@ -32,7 +32,7 @@ "LOGGLY_SUBDOMAIN": "example-subdomain", "LOGGLY_TOKEN": "example-token", "MAINTENANCE_MODE": "false", - "NODE_DB_URI": "mongodb://localhost/habitrpg", + "NODE_DB_URI": "mongodb://localhost:27017/habitrpg", "MONGODB_POOL_SIZE": "10", "NODE_ENV": "development", "PATH": "bin:node_modules/.bin:/usr/local/bin:/usr/bin:/bin", @@ -70,7 +70,7 @@ "SLACK_URL": "https://hooks.slack.com/services/some-url", "STRIPE_API_KEY": "aaaabbbbccccddddeeeeffff00001111", "STRIPE_PUB_KEY": "22223333444455556666777788889999", - "TEST_DB_URI": "mongodb://localhost/habitrpg_test", + "TEST_DB_URI": "mongodb://localhost:27017/habitrpg_test", "TRANSIFEX_SLACK_CHANNEL": "transifex", "WEB_CONCURRENCY": 1, "SKIP_SSL_CHECK_KEY": "key", diff --git a/website/server/libs/setupMongoose.js b/website/server/libs/setupMongoose.js index db7610426e..91eae637f9 100644 --- a/website/server/libs/setupMongoose.js +++ b/website/server/libs/setupMongoose.js @@ -8,9 +8,15 @@ const POOL_SIZE = nconf.get('MONGODB_POOL_SIZE'); // Do not connect to MongoDB when in maintenance mode if (MAINTENANCE_MODE !== 'true') { - const mongooseOptions = !IS_PROD ? {} : { + const commonOptions = { + useNewUrlParser: true, + useUnifiedTopology: true, + }; + + const mongooseOptions = !IS_PROD ? commonOptions : { keepAlive: 120, connectTimeoutMS: 30000, + ...commonOptions, }; if (POOL_SIZE) mongooseOptions.poolSize = Number(POOL_SIZE);