diff --git a/.travis.yml b/.travis.yml index 85b0f151..eab08e45 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,8 +15,8 @@ notifications: skip_join: false env: - - KVSTORE_BACKEND=mysql - - KVSTORE_BACKEND=memory + - KVSTORE_BACKEND=mysql TOOBUSY_MAX_LAG=0 + - KVSTORE_BACKEND=memory TOOBUSY_MAX_LAG=0 before_script: - "mysql -e 'DROP DATABASE IF EXISTS test;'" diff --git a/config/config.js b/config/config.js index 1d73eade..6671f9ad 100644 --- a/config/config.js +++ b/config/config.js @@ -221,6 +221,13 @@ module.exports = function (fs, path, url, convict) { default: path.resolve(__dirname, '../templates/email') } }, + toobusy: { + max_lag: { + doc: "Max event-loop lag before toobusy reports failure", + default: 70, + env: 'TOOBUSY_MAX_LAG' + } + }, dev: { verified: { doc: 'new Accounts should start already verified', diff --git a/server/server.js b/server/server.js index 06ccfa67..62800414 100644 --- a/server/server.js +++ b/server/server.js @@ -62,8 +62,12 @@ module.exports = function (path, url, Hapi, toobusy, error) { //TODO throttle extension - // twice the default max lag of 70ms - toobusy.maxLag(140) + // Enable toobusy, unless it has been preffed off in the config. + if (config.toobusy.max_lag > 0) { + toobusy.maxLag(config.toobusy.max_lag) + } else { + toobusy = function() { return false; } + } server.ext( 'onRequest',