Skip to content

Commit b513e61

Browse files
committed
Merge pull request #945 from Martii/someDepUpdates
Some dep updates Auto-merge... VPS still **not** accessible so won't be able to deploy
2 parents bb0228c + 0e4b3d8 commit b513e61

File tree

3 files changed

+47
-10
lines changed

3 files changed

+47
-10
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ Repository | Reference | Recent Version
7575
[select2][select2GHUrl] | [Documentation][select2DOCUrl] | [![NPM version][select2NPMVersionImage]][select2NPMUrl]
7676
[select2-bootstrap-css][select2-bootstrap-cssGHUrl] | [Documentation][select2-bootstrap-cssDOCUrl] | [![NPM version][select2-bootstrap-cssNPMVersionImage]][select2-bootstrap-cssNPMUrl]
7777
[serve-favicon][serve-faviconGHUrl] | [Documentation][serve-faviconDOCUrl] | [![NPM version][serve-faviconNPMVersionImage]][serve-faviconNPMUrl]
78+
[toobusy-js][toobusy-jsGHUrl] | [Documentation][toobusy-jsDOCUrl] | [![NPM version][toobusy-jsNPMVersionImage]][toobusy-jsNPMUrl]
7879
[uglifyJS2][uglifyJS2GHUrl] [¹][uglifyJS2GHHarmonyUrl] [²][uglifyJS2GHHarmony2Url] | [Documentation][uglifyJS2DOCUrl][¹][uglifyJS2DOC1Url] | [![NPM version][uglifyJS2NPMVersionImage]][uglifyJS2NPMUrl]
7980
[underscore][underscoreGHUrl] | [Documentation][underscoreDOCUrl] | [![NPM version][underscoreNPMVersionImage]][underscoreNPMUrl]
8081

@@ -403,6 +404,11 @@ Outdated dependencies list can also be achieved with `$ npm --depth 0 outdated`
403404
[serve-faviconNPMUrl]: https://www.npmjs.com/package/serve-favicon
404405
[serve-faviconNPMVersionImage]: https://img.shields.io/npm/v/serve-favicon.svg?style=flat
405406

407+
[toobusy-jsGHUrl]: https://github.com/STRML/node-toobusy
408+
[toobusy-jsDOCUrl]: https://github.com/STRML/node-toobusy/blob/master/README.md
409+
[toobusy-jsNPMUrl]: https://npmjs.com/package/toobusy-js
410+
[toobusy-jsNPMVersionImage]: https://img.shields.io/npm/v/toobusy-js.svg?style=flat
411+
406412
[uglifyJS2GHUrl]: https://github.com/mishoo/UglifyJS2
407413
[uglifyJS2GHHarmonyUrl]: https://github.com/mishoo/UglifyJS2/tree/harmony
408414
[uglifyJS2GHHarmony2Url]: https://github.com/OpenUserJs/UglifyJS2/tree/harmony-named

app.js

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ if (isPro) {
1717
var path = require('path');
1818

1919
var express = require('express');
20+
var toobusy = require('toobusy-js');
21+
var statusCodePage = require('./libs/templateHelpers').statusCodePage;
22+
2023
var methodOverride = require('method-override');
2124
var morgan = require('morgan');
2225
var bodyParser = require('body-parser');
@@ -111,14 +114,41 @@ db.on('reconnected', function () {
111114
});
112115

113116
process.on('SIGINT', function () {
114-
db.close(function () {
115-
console.log(chalk.green('MongoDB connection disconnected gracefully with app termination'));
116-
process.exit(0);
117-
});
117+
console.log(chalk.green('Capturing app termination for an attempt at cleanup'));
118+
119+
/**
120+
* Attempt to get everything closed before process exit
121+
*/
122+
123+
// Close the db connection
124+
db.close(); // NOTE: Current asynchronous but auth may prevent callback until completed
125+
126+
// Stop serving new http connections
127+
server.close(); // NOTE: Currently asynchronous but auth may prevent callback until completed
128+
129+
// Shutdown timer in toobusy
130+
toobusy.shutdown(); // NOTE: Currently synchronous
131+
132+
// Terminate the app
133+
process.exit(0);
118134
});
119135

120136
var sessionStore = new MongoStore({ mongooseConnection: db });
121137

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);
140+
app.use(function (aReq, aRes, aNext) {
141+
// check if we're toobusy
142+
if (toobusy()) {
143+
statusCodePage(aReq, aRes, aNext, {
144+
statusCode: 503,
145+
statusMessage: 'We\'re busy right now. Try again later.'
146+
});
147+
} else {
148+
aNext();
149+
}
150+
});
151+
122152
// Force HTTPS
123153
if (app.get('securePort')) {
124154
sslOptions = {

package.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
"dependencies": {
77
"ace-builds": "git://github.com/ajaxorg/ace-builds#4c15514",
88
"async": "1.5.2",
9-
"aws-sdk": "2.2.47",
9+
"aws-sdk": "2.3.1",
1010
"body-parser": "1.15.0",
1111
"bootstrap": "3.3.6",
1212
"bootstrap-markdown": "2.10.0",
1313
"chalk": "1.1.1",
14-
"clipboard": "1.5.9",
14+
"clipboard": "1.5.10",
1515
"compression": "1.6.1",
1616
"connect-mongo": "1.1.0",
1717
"cookie-parser": "1.4.1",
@@ -22,14 +22,14 @@
2222
"formidable": "1.0.17",
2323
"git-rev": "0.2.1",
2424
"github": "0.2.4",
25-
"highlight.js": "9.2.0",
26-
"jquery": "2.2.0",
25+
"highlight.js": "9.3.0",
26+
"jquery": "2.2.3",
2727
"jwt-simple": "0.5.0",
2828
"less-middleware": "2.1.0",
2929
"marked": "0.3.5",
3030
"method-override": "2.3.5",
3131
"moment": "2.12.0",
32-
"mongoose": "4.4.10",
32+
"mongoose": "4.4.11",
3333
"morgan": "1.7.0",
3434
"mu2": "0.5.20",
3535
"octicons": "3.5.0",
@@ -50,12 +50,13 @@
5050
"passport-windowslive": "1.0.2",
5151
"passport-yahoo": "0.3.0",
5252
"pegjs": "0.9.0",
53-
"request": "2.69.0",
53+
"request": "2.70.0",
5454
"rfc2047": "2.0.0",
5555
"sanitize-html": "1.11.4",
5656
"select2": "3.5.2-browserify",
5757
"select2-bootstrap-css": "1.4.6",
5858
"serve-favicon": "2.3.0",
59+
"toobusy-js": "0.4.3",
5960
"uglify-js-harmony": "git://github.com/OpenUserJs/UglifyJS2#harmony-named+cdba43c",
6061
"underscore": "1.8.3"
6162
},

0 commit comments

Comments
 (0)