diff --git a/lib/config/default.js b/lib/config/default.js index f7dc6511..867863aa 100644 --- a/lib/config/default.js +++ b/lib/config/default.js @@ -56,6 +56,8 @@ module.exports = { // socket.io heartbeatInterval: 5000, heartbeatTimeout: 10000, + // toobusy-js + responseMaxLag: 70, // document documentMaxLength: 100000, // image upload setting, available options are imgur/s3/filesystem/azure diff --git a/lib/config/environment.js b/lib/config/environment.js index 62a8f0a6..b4408ec3 100644 --- a/lib/config/environment.js +++ b/lib/config/environment.js @@ -33,6 +33,7 @@ module.exports = { dbURL: process.env.CMD_DB_URL, sessionSecret: process.env.CMD_SESSION_SECRET, sessionLife: toIntegerConfig(process.env.CMD_SESSION_LIFE), + responseMaxLag: toIntegerConfig(process.env.CMD_RESPONSE_MAX_LAG), imageUploadType: process.env.CMD_IMAGE_UPLOAD_TYPE, imgur: { clientID: process.env.CMD_IMGUR_CLIENTID diff --git a/lib/config/hackmdEnvironment.js b/lib/config/hackmdEnvironment.js index fb16dbc2..7765e0af 100644 --- a/lib/config/hackmdEnvironment.js +++ b/lib/config/hackmdEnvironment.js @@ -28,6 +28,7 @@ module.exports = { dbURL: process.env.HMD_DB_URL, sessionSecret: process.env.HMD_SESSION_SECRET, sessionLife: toIntegerConfig(process.env.HMD_SESSION_LIFE), + responseMaxLag: toIntegerConfig(process.env.HMD_RESPONSE_MAX_LAG), imageUploadType: process.env.HMD_IMAGE_UPLOAD_TYPE, imgur: { clientID: process.env.HMD_IMGUR_CLIENTID diff --git a/lib/web/middleware/tooBusy.js b/lib/web/middleware/tooBusy.js index f1b72330..78f3e49a 100644 --- a/lib/web/middleware/tooBusy.js +++ b/lib/web/middleware/tooBusy.js @@ -2,8 +2,11 @@ const toobusy = require('toobusy-js') +const config = require('../../config') const response = require('../../response') +toobusy.maxLag(config.responseMaxLag); + module.exports = function (req, res, next) { if (toobusy()) { response.errorServiceUnavailable(res)