зеркало из https://github.com/mozilla/CSOL-site.git
Merge remote-tracking branch 'erik/mandrill-health-monitor'
This commit is contained in:
Коммит
26b71fd3ff
3
app.js
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)
|
||||
}
|
||||
});
|
||||
|
||||
|
|
23
mandrill.js
23
mandrill.js
|
@ -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();
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче