cleaned up health check a little

This commit is contained in:
Henry Oswald 2016-02-04 13:44:17 +00:00
parent b53dd50340
commit 35e0eafc95

View file

@ -26,18 +26,21 @@ module.exports =
opts.json = true opts.json = true
request.get opts, (err, res, body)-> request.get opts, (err, res, body)->
if res.statusCode != 200 if res.statusCode != 200
return cb("status code not 200, its #{res.statusCode}") e = "status code not 200 #{res.statusCode}"
logger.err err:err, e
return cb(e)
hasNotification = _.some body, (notification)-> hasNotification = _.some body, (notification)->
notification.key == notification_key and notification.user_id == user_id.toString() notification.key == notification_key and notification.user_id == user_id.toString()
if hasNotification if hasNotification
cb(null,body) cb(null, body)
else else
logger.log body:body, "what is in the body" logger.log body:body, "got notifications response for health check"
return cb("notification not found in response") return cb("notification not found in response")
] ]
async.series jobs, (err, body)-> async.series jobs, (err, body)->
if err? if err?
logger.err err:err, "error running health check"
return callback(err) return callback(err)
else else
notification_id = body[1][0]._id notification_id = body[1][0]._id