Merge pull request #6962 from overleaf/jpa-clsi-tweak-health-check

[clsi] tweak health check

GitOrigin-RevId: 2caad90d55bb441c7008e3084b34d683b072dfbd
This commit is contained in:
Jakob Ackermann 2022-03-02 12:59:57 +00:00 committed by Copybot
parent a3e85f5357
commit b25ff076b8
3 changed files with 18 additions and 1 deletions

View file

@ -271,10 +271,18 @@ if (Settings.processLifespanLimitMs) {
function runSmokeTest() {
if (Settings.processTooOld) return
const INTERVAL = 30 * 1000
if (
smokeTest.lastRunSuccessful() &&
Date.now() - CompileController.lastSuccessfulCompile < INTERVAL / 2
) {
logger.log('skipping smoke tests, got recent successful user compile')
return setTimeout(runSmokeTest, INTERVAL / 2)
}
logger.log('running smoke tests')
smokeTest.triggerRun(err => {
if (err) logger.error({ err }, 'smoke tests failed')
setTimeout(runSmokeTest, 30 * 1000)
setTimeout(runSmokeTest, INTERVAL)
})
}
if (Settings.smokeTest) {

View file

@ -27,6 +27,8 @@ function isImageNameAllowed(imageName) {
}
module.exports = CompileController = {
lastSuccessfulCompile: 0,
compile(req, res, next) {
if (next == null) {
next = function () {}
@ -87,6 +89,7 @@ module.exports = CompileController = {
for (file of Array.from(outputFiles)) {
if (file.path === 'output.pdf' && file.size > 0) {
status = 'success'
CompileController.lastSuccessfulCompile = Date.now()
}
}

View file

@ -19,6 +19,9 @@ module.exports = {
cb(error)
})
},
lastRunSuccessful() {
return this._lastError == null
},
_lastError: new Error('SmokeTestsPending'),
_sendResponse(res, error) {
@ -39,6 +42,9 @@ module.exports = {
url,
json: {
compile: {
options: {
metricsPath: 'health-check',
},
resources: [
{
path: 'main.tex',