+ This forum is temporarily unavailable due to excessive load.
+ We shouldn't be down for long. Please check back shortly. Sorry for the inconvenience!
+
+
+ Alright. You can stop clicking... it's not going to make the site come back sooner!
+
+
+
+
+
diff --git a/public/language/en_GB/pages.json b/public/language/en_GB/pages.json
index f398d5b1ff..b5dbc7140a 100644
--- a/public/language/en_GB/pages.json
+++ b/public/language/en_GB/pages.json
@@ -42,5 +42,7 @@
"account/watched": "Topics watched by %1",
"maintenance.text": "%1 is currently undergoing maintenance. Please come back another time.",
- "maintenance.messageIntro": "Additionally, the administrator has left this message:"
+ "maintenance.messageIntro": "Additionally, the administrator has left this message:",
+
+ "throttled.text": "%1 is currently unavailable due to excessive load. Please come back another time."
}
\ No newline at end of file
diff --git a/src/middleware/middleware.js b/src/middleware/middleware.js
index 6b8447bc57..89416cd929 100644
--- a/src/middleware/middleware.js
+++ b/src/middleware/middleware.js
@@ -11,13 +11,13 @@ var app,
validator = require('validator'),
nconf = require('nconf'),
ensureLoggedIn = require('connect-ensure-login'),
+ toobusy = require('toobusy-js'),
plugins = require('../plugins'),
meta = require('../meta'),
user = require('../user'),
groups = require('../groups'),
-
analytics = require('../analytics'),
controllers = {
@@ -25,6 +25,9 @@ var app,
helpers: require('../controllers/helpers')
};
+toobusy.maxLag(parseInt(meta.config.eventLoopLagThreshold, 10) || 70);
+toobusy.interval(parseInt(meta.config.eventLoopInterval, 10) || 500);
+
middleware.authenticate = function(req, res, next) {
if (req.user) {
return next();
@@ -217,6 +220,13 @@ middleware.privateUploads = function(req, res, next) {
next();
};
+middleware.busyCheck = function(req, res, next) {
+ if (toobusy()) {
+ res.type('text/html').sendFile(path.join(__dirname, '../../public/503.html'));
+ } else {
+ next();
+ }
+};
module.exports = function(webserver) {
app = webserver;
diff --git a/src/routes/helpers.js b/src/routes/helpers.js
index 3cd1524fc5..3dcca80bc4 100644
--- a/src/routes/helpers.js
+++ b/src/routes/helpers.js
@@ -5,7 +5,7 @@ var helpers = {};
helpers.setupPageRoute = function(router, name, middleware, middlewares, controller) {
middlewares = middlewares.concat([middleware.pageView, middleware.pluginHooks]);
- router.get(name, middleware.buildHeader, middlewares, controller);
+ router.get(name, middleware.busyCheck, middleware.buildHeader, middlewares, controller);
router.get('/api' + name, middlewares, controller);
};
diff --git a/src/views/admin/settings/advanced.tpl b/src/views/admin/settings/advanced.tpl
index f6c3417082..3a0a314106 100644
--- a/src/views/admin/settings/advanced.tpl
+++ b/src/views/admin/settings/advanced.tpl
@@ -41,4 +41,33 @@
+
+
Traffic Management
+
+
+ NodeBB deploys equipped with a module that automatically denies requests in high-traffic
+ situations. You can tune these settings here, although the defaults are a good starting
+ point.
+