Skip to content

Commit 9fe6ae8

Browse files
committed
Merge pull request #947 from Martii/Issue-944forceBusy
Create a BUSY landing page Auto-merge
2 parents 2e0ab83 + 83fde21 commit 9fe6ae8

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

app.js

+27-4
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,36 @@ process.on('SIGINT', function () {
136136
var sessionStore = new MongoStore({ mongooseConnection: db });
137137

138138
// See https://hacks.mozilla.org/2013/01/building-a-node-js-server-that-wont-melt-a-node-js-holiday-season-part-5/
139-
toobusy.maxLag(100);
139+
toobusy.maxLag(process.env.BUSY_LAG || 100);
140140
app.use(function (aReq, aRes, aNext) {
141-
// check if we're toobusy
142-
if (toobusy()) {
141+
var pathname = null;
142+
143+
if (process.env.FORCE_BUSY_ABSOLUTE === 'true') { // check for absolute forced busy
144+
aRes.status(503).send(); // NOTE: No UI period just response header
145+
146+
} else if (process.env.FORCE_BUSY === 'true') { // check for graceful forced busy
147+
pathname = aReq._parsedUrl.pathname;
148+
149+
if (
150+
/^\/favicon\.ico$/.test(pathname) ||
151+
/^\/redist\//.test(pathname) ||
152+
/^\/less\//.test(pathname) ||
153+
/^\/css\//.test(pathname) ||
154+
/^\/images\//.test(pathname) ||
155+
/^\/fonts\//.test(pathname)
156+
) {
157+
aNext(); // NOTE: Allow styling pass through on these routes
158+
} else {
159+
statusCodePage(aReq, aRes, aNext, {
160+
statusCode: 503,
161+
statusMessage:
162+
'We are experiencing technical difficulties right now. Please try again later.'
163+
});
164+
}
165+
} else if (toobusy()) { // check if we're toobusy
143166
statusCodePage(aReq, aRes, aNext, {
144167
statusCode: 503,
145-
statusMessage: 'We\'re busy right now. Try again later.'
168+
statusMessage: 'We are busy right now. Please try again later.'
146169
});
147170
} else {
148171
aNext();

0 commit comments

Comments
 (0)