diff --git a/services/clsi/app.js b/services/clsi/app.js index 61b186d0c4..bd1e9419cf 100644 --- a/services/clsi/app.js +++ b/services/clsi/app.js @@ -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) { diff --git a/services/clsi/app/js/CompileController.js b/services/clsi/app/js/CompileController.js index 5180d1dc2e..e570838051 100644 --- a/services/clsi/app/js/CompileController.js +++ b/services/clsi/app/js/CompileController.js @@ -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() } } diff --git a/services/clsi/test/smoke/js/SmokeTests.js b/services/clsi/test/smoke/js/SmokeTests.js index 0c207e660e..18aa562a0b 100644 --- a/services/clsi/test/smoke/js/SmokeTests.js +++ b/services/clsi/test/smoke/js/SmokeTests.js @@ -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',