-
-
Notifications
You must be signed in to change notification settings - Fork 17.6k
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
Express 3 has no "app.close()" #1366
Comments
Whole express is in fact stuff around one function; vice versa express app is |
Yes express is really a listener to http request events now which means you can do this: var app = express(); On Oct 13, 2012, at 1:38 AM, Glynn Bird notifications@github.com wrote:
|
yup, if you happen to use the "shortcut" |
So the final full code example for cleaning up resources in Express 3 would be the following?:
|
I doubt setTimeout works here after a SIGTERM event because the main event loop won't accept any new events anymore. |
If anyone ever reaches this issue via Google, the following snippet works with Express 4: var app = express();
var server = app.listen(8080, function() {
console.log('Listening :)');
server.close(function() { console.log('Doh :('); });
}); |
Imagine you want to be able to terminate your Node.js app and drain all existing connections before quitting, you might come up with a solution as outlined here:
http://blog.argteam.com/coding/hardening-node-js-for-production-part-3-zero-downtime-deployments-with-nginx
e.g.
This would all you to do graceful deployments of new code without terminating existing requests (assuming your load balancer sends traffic to other servers).
As of Express 3, the app.close() method seems to have disappeared, which means Express users have no means of gracefully stopping an application as far as I can see.
The text was updated successfully, but these errors were encountered: