Skip to content

Commit

Permalink
merge express.js example update from @jacobmarble, closes #6
Browse files Browse the repository at this point in the history
  • Loading branch information
lloyd committed Jan 17, 2013
2 parents 525c14d + 4e86f01 commit f5c9171
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ and continue serving as many requests as possible.
var toobusy = require('toobusy'),
express = require('express');

var app = express.createServer();
var app = express();

// middleware which blocks requests when we're too busy
app.use(function(req, res, next) {
Expand All @@ -48,12 +48,13 @@ and continue serving as many requests as possible.
res.send("I counted to " + i);
});

app.listen(3000);
var server = app.listen(3000);

process.on('SIGINT', function() {
app.close();
server.close();
// calling .shutdown allows your process to exit normally
toobusy.shutdown();
process.exit();
});

## tunable parameters
Expand Down
6 changes: 3 additions & 3 deletions examples/express.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var toobusy = require('..'),
express = require('express');

var app = express.createServer();
var app = express();

// Have grace under load
app.use(function(req, res, next) {
Expand All @@ -19,9 +19,9 @@ app.get('/', function(req, res) {
res.send("I counted to " + i);
});

app.listen(3000);
var server = app.listen(3000);

process.on('SIGINT', function() {
app.close();
server.close();
toobusy.shutdown();
});

0 comments on commit f5c9171

Please sign in to comment.