Skip to content

Instantly share code, notes, and snippets.

@L8D
Last active August 28, 2015 06:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save L8D/5e8eae75efa3c80b6e87 to your computer and use it in GitHub Desktop.
Save L8D/5e8eae75efa3c80b6e87 to your computer and use it in GitHub Desktop.
Setting ExpressJS server timeout using best practices
var express = require('express'),
http = require('http'),
app = express();
var server = http.createServer(app);
var timeout = 0;
server.setTimeout(timeout, function() {
server.listen(app.get('port'), function() {
console.log("Express server listening on port %d in %s mode", app.get('port'), app.get('env'));
});
});
@gnz00
Copy link

gnz00 commented Aug 28, 2015

What's the best practice for getting this to stay alive. Execution finishes before the server.listen process gets kicked off.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment