Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some dep updates #945

Merged
merged 1 commit into from
Apr 6, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ Repository | Reference | Recent Version
[select2][select2GHUrl] | [Documentation][select2DOCUrl] | [![NPM version][select2NPMVersionImage]][select2NPMUrl]
[select2-bootstrap-css][select2-bootstrap-cssGHUrl] | [Documentation][select2-bootstrap-cssDOCUrl] | [![NPM version][select2-bootstrap-cssNPMVersionImage]][select2-bootstrap-cssNPMUrl]
[serve-favicon][serve-faviconGHUrl] | [Documentation][serve-faviconDOCUrl] | [![NPM version][serve-faviconNPMVersionImage]][serve-faviconNPMUrl]
[toobusy-js][toobusy-jsGHUrl] | [Documentation][toobusy-jsDOCUrl] | [![NPM version][toobusy-jsNPMVersionImage]][toobusy-jsNPMUrl]
[uglifyJS2][uglifyJS2GHUrl] [¹][uglifyJS2GHHarmonyUrl] [²][uglifyJS2GHHarmony2Url] | [Documentation][uglifyJS2DOCUrl][¹][uglifyJS2DOC1Url] | [![NPM version][uglifyJS2NPMVersionImage]][uglifyJS2NPMUrl]
[underscore][underscoreGHUrl] | [Documentation][underscoreDOCUrl] | [![NPM version][underscoreNPMVersionImage]][underscoreNPMUrl]

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

[toobusy-jsGHUrl]: https://github.com/STRML/node-toobusy
[toobusy-jsDOCUrl]: https://github.com/STRML/node-toobusy/blob/master/README.md
[toobusy-jsNPMUrl]: https://npmjs.com/package/toobusy-js
[toobusy-jsNPMVersionImage]: https://img.shields.io/npm/v/toobusy-js.svg?style=flat

[uglifyJS2GHUrl]: https://github.com/mishoo/UglifyJS2
[uglifyJS2GHHarmonyUrl]: https://github.com/mishoo/UglifyJS2/tree/harmony
[uglifyJS2GHHarmony2Url]: https://github.com/OpenUserJs/UglifyJS2/tree/harmony-named
Expand Down
38 changes: 34 additions & 4 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ if (isPro) {
var path = require('path');

var express = require('express');
var toobusy = require('toobusy-js');
var statusCodePage = require('./libs/templateHelpers').statusCodePage;

var methodOverride = require('method-override');
var morgan = require('morgan');
var bodyParser = require('body-parser');
Expand Down Expand Up @@ -111,14 +114,41 @@ db.on('reconnected', function () {
});

process.on('SIGINT', function () {
db.close(function () {
console.log(chalk.green('MongoDB connection disconnected gracefully with app termination'));
process.exit(0);
});
console.log(chalk.green('Capturing app termination for an attempt at cleanup'));

/**
* Attempt to get everything closed before process exit
*/

// Close the db connection
db.close(); // NOTE: Current asynchronous but auth may prevent callback until completed

// Stop serving new http connections
server.close(); // NOTE: Currently asynchronous but auth may prevent callback until completed

// Shutdown timer in toobusy
toobusy.shutdown(); // NOTE: Currently synchronous

// Terminate the app
process.exit(0);
});

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

// See https://hacks.mozilla.org/2013/01/building-a-node-js-server-that-wont-melt-a-node-js-holiday-season-part-5/
toobusy.maxLag(100);
app.use(function (aReq, aRes, aNext) {
// check if we're toobusy
if (toobusy()) {
statusCodePage(aReq, aRes, aNext, {
statusCode: 503,
statusMessage: 'We\'re busy right now. Try again later.'
});
} else {
aNext();
}
});

// Force HTTPS
if (app.get('securePort')) {
sslOptions = {
Expand Down
13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
"dependencies": {
"ace-builds": "git://github.com/ajaxorg/ace-builds#4c15514",
"async": "1.5.2",
"aws-sdk": "2.2.47",
"aws-sdk": "2.3.1",
"body-parser": "1.15.0",
"bootstrap": "3.3.6",
"bootstrap-markdown": "2.10.0",
"chalk": "1.1.1",
"clipboard": "1.5.9",
"clipboard": "1.5.10",
"compression": "1.6.1",
"connect-mongo": "1.1.0",
"cookie-parser": "1.4.1",
Expand All @@ -22,14 +22,14 @@
"formidable": "1.0.17",
"git-rev": "0.2.1",
"github": "0.2.4",
"highlight.js": "9.2.0",
"jquery": "2.2.0",
"highlight.js": "9.3.0",
"jquery": "2.2.3",
"jwt-simple": "0.5.0",
"less-middleware": "2.1.0",
"marked": "0.3.5",
"method-override": "2.3.5",
"moment": "2.12.0",
"mongoose": "4.4.10",
"mongoose": "4.4.11",
"morgan": "1.7.0",
"mu2": "0.5.20",
"octicons": "3.5.0",
Expand All @@ -50,12 +50,13 @@
"passport-windowslive": "1.0.2",
"passport-yahoo": "0.3.0",
"pegjs": "0.9.0",
"request": "2.69.0",
"request": "2.70.0",
"rfc2047": "2.0.0",
"sanitize-html": "1.11.4",
"select2": "3.5.2-browserify",
"select2-bootstrap-css": "1.4.6",
"serve-favicon": "2.3.0",
"toobusy-js": "0.4.3",
"uglify-js-harmony": "git://github.com/OpenUserJs/UglifyJS2#harmony-named+cdba43c",
"underscore": "1.8.3"
},
Expand Down