2015-03-01 07:45:23 -05:00
|
|
|
request = require("request")
|
|
|
|
logger = require 'logger-sharelatex'
|
|
|
|
settings = require 'settings-sharelatex'
|
|
|
|
|
|
|
|
module.exports =
|
|
|
|
|
|
|
|
healthCheck: (req, res)->
|
|
|
|
opts =
|
2015-03-01 07:53:10 -05:00
|
|
|
url: "http://localhost:3005/user/#{settings.healthCheckUserId}/check"
|
2015-03-01 07:45:23 -05:00
|
|
|
json:
|
|
|
|
words:["helllo"]
|
|
|
|
language: "en"
|
2015-03-01 07:56:31 -05:00
|
|
|
timeout: 1000 * 20
|
2015-03-01 07:45:23 -05:00
|
|
|
request.post opts, (err, response, body)->
|
|
|
|
console.log body?.misspellings[0]?.suggestions.length
|
|
|
|
numberOfSuggestions = body?.misspellings[0]?.suggestions?.length
|
|
|
|
if numberOfSuggestions > 10
|
|
|
|
logger.log "health check passed"
|
|
|
|
res.send 200
|
|
|
|
else
|
|
|
|
logger.err body:body, numberOfSuggestions:numberOfSuggestions, "health check failed"
|
|
|
|
res.send 500
|