Skip to content

Commit

Permalink
Change some defaults with MongoDB and stderr
Browse files Browse the repository at this point in the history
* Set some DB options to their assumed defaults from http://mongodb.github.io/node-mongodb-native/2.0/api/Server.html ... relates to https://github.com/christkv/mongodb-core/issues/66#issuecomment-165052045
* Set some replset defaults to their assumed defaults from http://mongodb.github.io/node-mongodb-native/2.0/api/ReplSet.html ... relates to Automattic/mongoose#3588 (comment)
* Move/change a stderr message to debug mode of *node*... clear up the logs a bit since script source may not be found just yet. This only happens on pro so far and probably deals with streams not ready yet. Applies to OpenUserJS#430
* Move S3 source not found stderr to debug mode of *node*... known issue of OpenUserJS#486. Applies to OpenUserJS#430

**NOTES**
* This will be a test whereas unless it's a huge bug I can't take pro down for at least 3 days, give or take to see if this helps or hinders from OpenUserJS#845 backout.
  • Loading branch information
Martii committed Dec 16, 2015
1 parent a18c315 commit bb16868
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
25 changes: 22 additions & 3 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,32 @@ var settings = require('./models/settings.json');
var connectStr = process.env.CONNECT_STRING || settings.connect;
var sessionSecret = process.env.SESSION_SECRET || settings.secret;
var db = mongoose.connection;

var dbOptions = {
server: {
poolSize: 5,
socketOptions: {
keepAlive: 1
autoReconnect: false,
noDelay: true,
keepAlive: 1,
connectTimeoutMS: 0,
socketTimeoutMS: 0
},
reconnectTries: 60,
reconnectInterval: 4000
reconnectTries: 30,
reconnectInterval: 1000
}
};

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

Expand Down
7 changes: 5 additions & 2 deletions controllers/scriptStorage.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,16 @@ exports.getSource = function (aReq, aCallback) {

if (!aScript) {
aCallback(null);
console.warn('no script found' );
if (isDbg) {
console.warn('no script found yet' );
}
return;
}

s3Object = s3.getObject({ Bucket: bucketName, Key: installNameBase + (isLib ? '.js' : '.user.js') }).createReadStream().
on('error', function () {
if (isPro) {
// TODO: #486
if (isDbg) {
console.error('S3 Key Not Found ' + installNameBase + (isLib ? '.js' : '.user.js'));
}

Expand Down

0 comments on commit bb16868

Please sign in to comment.