diff --git a/services/spelling/app/coffee/HealthCheckController.coffee b/services/spelling/app/coffee/HealthCheckController.coffee new file mode 100644 index 0000000000..08acf7c4d0 --- /dev/null +++ b/services/spelling/app/coffee/HealthCheckController.coffee @@ -0,0 +1,21 @@ +request = require("request") +logger = require 'logger-sharelatex' +settings = require 'settings-sharelatex' + +module.exports = + + healthCheck: (req, res)-> + opts = + url: "http://localhost:#{settings.internal.spelling.port}/user/#{settings.healthCheckUserId}/check" + json: + words:["helllo"] + language: "en" + 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 diff --git a/services/spelling/package.json b/services/spelling/package.json index 6d582021ce..01e236bea1 100644 --- a/services/spelling/package.json +++ b/services/spelling/package.json @@ -6,7 +6,7 @@ "type": "git", "url": "https://github.com/sharelatex/spelling-sharelatex.git" }, - "version": "0.1.0", + "version": "0.1.3", "dependencies": { "async": "0.1.22", "express": "3.1.0",