@@ -136,13 +136,36 @@ process.on('SIGINT', function () {
136
136
var sessionStore = new MongoStore ( { mongooseConnection : db } ) ;
137
137
138
138
// 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 ) ;
140
140
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
+ / ^ \/ f a v i c o n \. i c o $ / . test ( pathname ) ||
151
+ / ^ \/ r e d i s t \/ / . test ( pathname ) ||
152
+ / ^ \/ l e s s \/ / . test ( pathname ) ||
153
+ / ^ \/ c s s \/ / . test ( pathname ) ||
154
+ / ^ \/ i m a g e s \/ / . test ( pathname ) ||
155
+ / ^ \/ f o n t s \/ / . 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
143
166
statusCodePage ( aReq , aRes , aNext , {
144
167
statusCode : 503 ,
145
- statusMessage : 'We\'re busy right now. Try again later.'
168
+ statusMessage : 'We are busy right now. Please try again later.'
146
169
} ) ;
147
170
} else {
148
171
aNext ( ) ;
0 commit comments