paypal/kraken-js — pull request #21 by sean (2013-11-24 02:25:04+00:00)
Title: [Issue #7] Add support for graceful shutdowns.

With this change hitting Control+C or sending kill -{2,15} (SIGINT or SIGTERM) will cause the server to shutdown gracefully draining any connections. Clients which connect will see this message:

> Server is in the process of restarting.

If the connections are drained successfully prior to the timeout, stdout will display:

> Received kill signal, shutting down gracefully.
> Closed out remaining connections.

and the exit code will be 0. Otherwise you'll see:

> Received kill signal, shutting down gracefully.
> Could not close connections in time, forcefully shutting down.

and the exit code will be 1. The timeout is hardcoded at 30s, perhaps this should be configurable.