Merge remote-tracking branch 'erik/mandrill-health-monitor'

This commit is contained in:
Atul Varma 2013-06-03 20:44:57 -04:00
Родитель 69ac993655 c3ad019bf0
Коммит 26b71fd3ff
2 изменённых файлов: 23 добавлений и 3 удалений

3
app.js
Просмотреть файл

@ -22,7 +22,8 @@ const healthChecker = healthCheck({
s3: healthCheck.checker(require('./s3').healthCheck),
database: healthCheck.checker(require('./db').healthCheck),
openbadger: healthCheck.checker(require('./openbadger').healthCheck),
aestimia: healthCheck.checker(require('./aestimia').healthCheck)
aestimia: healthCheck.checker(require('./aestimia').healthCheck),
mandrill: healthCheck.checker(require('./mandrill').healthCheck)
}
});

Просмотреть файл

@ -7,10 +7,10 @@ const FAKE_EMAIL = ('DEBUG' in process.env)
var request = require('request');
if (FAKE_EMAIL) {
request.post = function(opts, cb) {
request = { post : function(opts, cb) {
logger.log('debug', 'FAKE EMAIL: request.post with opts', opts);
cb('EMAIL DISABLED');
};
} };
}
const ENDPOINT = process.env['CSOL_MANDRILL_URL'] ||
@ -114,3 +114,22 @@ module.exports = {
});
}
};
module.exports.healthCheck = function(cb) {
var opts = {
url: url.resolve(ENDPOINT, 'users/ping.json'),
json: { key: KEY }
};
request.post(opts, function(err, response, body) {
if (err)
return cb(err);
if (body.code === -1)
return cb(body.message);
return cb();
});
};