Skip to content

Commit

Permalink
Update readme.md
Browse files Browse the repository at this point in the history
  • Loading branch information
thedillonb committed Nov 25, 2015
1 parent eb5f671 commit 630c368
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion readme.md
@@ -1,5 +1,12 @@
# Http-Shutdown ![](https://img.shields.io/travis/thedillonb/http-shutdown.svg?style=flat-square) ![](https://img.shields.io/coveralls/thedillonb/http-shutdown.svg) ![](https://img.shields.io/npm/v/http-shutdown.svg?style=flat-square)
Shutdown a Nodejs HTTP server gracefully by terminating the listening socket, then destroying all keep-alive idle sockets all while allowing in-flight requests to finish. Don't be fooled by other "shutdown" techniques. This solution is complete and takes into account many factors left out by other solutions.
Shutdown a Nodejs HTTP server gracefully by doing the following:

1. Close the listening socket to prevent new connections
2. Close all idle keep-alive sockets to prevent new requests during shutdown
3. Wait for all in-flight requests to finish before closing their sockets.
4. Profit!

Other solutions might just use `server.close` which only terminates the listening socket and waits for other sockets to close - which is incomplete since keep-alive sockets can still make requests. Or, they may use `ref()/unref()` to simply cause Nodejs to terminate if the sockets are idle - which doesn't help if you have other things to shutdown after the server shutsdown. `http-shutdown` is a complete solution. It uses idle indicators combined with an active socket list to safely, and gracefully, close all sockets. It does not use `ref()/unref()` but, instead, actively closes connections as they finish meaning that socket 'close' events still work correctly since the sockets are actually closing - you're not just `unref`ing and forgetting about them.

## Installation

Expand Down

0 comments on commit 630c368

Please sign in to comment.