Skip to content

Commit

Permalink
Handle all redis errors
Browse files Browse the repository at this point in the history
fixes issue mozilla#30
  • Loading branch information
Shane Tomlinson committed Dec 21, 2012
1 parent 2b22217 commit e4673d7
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 5 deletions.
2 changes: 1 addition & 1 deletion server/bin/email
Expand Up @@ -2,7 +2,7 @@
/* -*- Mode: js2; js2-basic-offset: 2; indent-tabs-mode: nil; -*- */

var smtp = require('smtp-protocol'),
redis = require("redis"),
redis = require("../lib/redis"),
logEvent = require("../lib/events").logEvent,
MailParser = require("mailparser").MailParser;

Expand Down
2 changes: 1 addition & 1 deletion server/lib/api.js
Expand Up @@ -6,7 +6,7 @@ const jwcrypto = require('jwcrypto'),
path = require('path'),
bid = require('./bid'),
unixTime = require('./time').unixTime,
redis = require('redis'),
redis = require('./redis'),
logEvent = require('./events').logEvent,
ALGORITHM = "RS",
KEYSIZE = 256,
Expand Down
2 changes: 1 addition & 1 deletion server/lib/bid.js
Expand Up @@ -4,7 +4,7 @@

const util = require('util'),
events = require('events'),
redis = require('redis'),
redis = require('./redis'),
redisConf = require('./config'),
wsapi = require('./wsapi_client'),
logEvent = require('./events').logEvent,
Expand Down
4 changes: 2 additions & 2 deletions server/lib/events.js
@@ -1,4 +1,4 @@
const redis = require('redis'),
const redis = require('./redis'),
db = redis.createClient();

/**
Expand Down Expand Up @@ -48,4 +48,4 @@ var fetchEvents = module.exports.fetchEvents = function fetchEvents(email, start
}
return callback(null, stream);
});
};
};
20 changes: 20 additions & 0 deletions server/lib/redis.js
@@ -0,0 +1,20 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

const redis = require('redis');

var redisErrorCount = 0;

exports.createClient = function() {
var client = redis.createClient();

client.on('error', function(err) {
// The error has to be handled or else node restarts the server. Not ideal.
console.log("REDIS error", redisErrorCount, err);
redisErrorCount++;
});

return client;
};

0 comments on commit e4673d7

Please sign in to comment.