Skip to content

Commit

Permalink
Change some more defaults with MongoDB
Browse files Browse the repository at this point in the history
* Change logic to only use `replset` on production ... as per Automattic/mongoose#3588 (comment) from @chrisckchang
* Default to single connection on development with `server` ... as per Automattic/mongoose#3588 (comment) from @chrisckchang
* Change `connectTimeoutMS` to 60 seconds instead of presumed inherited OS value from https://github.com/christkv/mongodb-core/issues/66#issuecomment-165052045 by @christkv and overridden with @chrisckchang recommendation previously mentioned in commit summary.
* Added NOTE on non-standard keepAlive value that was in before I started twiddling with this... this was on dev and pro pre replica/sharding set.

Applies to OpenUserJS#845, OpenUserJS#851, OpenUserJS#852, Automattic/mongoose#3588 and loosely christkv/mongodb-core#66

Refs:
* Automattic/mongoose#3588 (comment)
  • Loading branch information
Martii committed Dec 18, 2015
1 parent 665f904 commit 437957d
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,33 +46,32 @@ var connectStr = process.env.CONNECT_STRING || settings.connect;
var sessionSecret = process.env.SESSION_SECRET || settings.secret;
var db = mongoose.connection;

var dbOptions = {
server: {
var dbOptions = {};
if (isPro) {
dbOptions.replset = {
poolSize: 5,
socketOptions: {
autoReconnect: false,
noDelay: true,
keepAlive: 1,
connectTimeoutMS: 0,
keepAlive: 1, // NOTE: Unclear why this was non-zero early on
connectTimeoutMS: 60 * 1000,
socketTimeoutMS: 0
},
reconnectTries: 30,
reconnectInterval: 1000
}
};

if (isPro) {
dbOptions.replset = {
} else {
dbOptions.server = {
secondaryAcceptableLatencyMS: 15,
poolSize: 5,
socketOptions: {
noDelay: true,
keepAlive: 0,
connectTimeoutMS: 0,
connectTimeoutMS: 60 * 1000,
socketTimeoutMS: 0
}
}
};
}

var fs = require('fs');
var http = require('http');
Expand Down

0 comments on commit 437957d

Please sign in to comment.