mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
add timeout to health check requests and always try the delete
This commit is contained in:
parent
de9a24f7bb
commit
4f5669591a
1 changed files with 10 additions and 7 deletions
|
@ -10,6 +10,7 @@ logger = require "logger-sharelatex"
|
||||||
|
|
||||||
module.exports =
|
module.exports =
|
||||||
check : (callback)->
|
check : (callback)->
|
||||||
|
getOpts = -> {url:url, timeout:3000}
|
||||||
doc_id = ObjectId()
|
doc_id = ObjectId()
|
||||||
project_id = ObjectId(settings.docstore.healthCheck.project_id)
|
project_id = ObjectId(settings.docstore.healthCheck.project_id)
|
||||||
url = "http://localhost:#{port}/project/#{project_id}/doc/#{doc_id}"
|
url = "http://localhost:#{port}/project/#{project_id}/doc/#{doc_id}"
|
||||||
|
@ -17,19 +18,21 @@ module.exports =
|
||||||
logger.log lines:lines, url:url, doc_id:doc_id, project_id:project_id, "running health check"
|
logger.log lines:lines, url:url, doc_id:doc_id, project_id:project_id, "running health check"
|
||||||
jobs = [
|
jobs = [
|
||||||
(cb)->
|
(cb)->
|
||||||
opts =
|
opts = getOpts()
|
||||||
url:url
|
opts.json = {lines: lines}
|
||||||
json: {lines: lines}
|
|
||||||
request.post(opts, cb)
|
request.post(opts, cb)
|
||||||
(cb)->
|
(cb)->
|
||||||
request.get {url:url, json:true}, (err, res, body)->
|
opts = getOpts()
|
||||||
|
opts.json = true
|
||||||
|
request.get opts, (err, res, body)->
|
||||||
if res.statusCode != 200
|
if res.statusCode != 200
|
||||||
cb("status code not 200, its #{res.statusCode}")
|
cb("status code not 200, its #{res.statusCode}")
|
||||||
else if _.isEqual(body.lines, lines) and body._id == doc_id.toString()
|
else if _.isEqual(body.lines, lines) and body._id == doc_id.toString()
|
||||||
cb()
|
cb()
|
||||||
else
|
else
|
||||||
cb("health check lines not equal #{body.lines} != #{lines}")
|
cb("health check lines not equal #{body.lines} != #{lines}")
|
||||||
(cb)->
|
|
||||||
request.del url, cb
|
|
||||||
]
|
]
|
||||||
async.series jobs, callback
|
async.series jobs, (err)->
|
||||||
|
if err?
|
||||||
|
callback(err)
|
||||||
|
request.del getOpts(), callback
|
||||||
|
|
Loading…
Reference in a new issue