mozilla-services/pushgo — pull request #178 by kitcambridge (2014-12-20 23:58:28+00:00)
Title: Add graceful shutdown

Adds graceful shutdown per #139. `Application.Close()` performs the following steps:

* Stops the HTTP `/update` listener and closes all open TCP connections. This should deregister the instance from the ELB.
* Deregisters from the balancer, waiting for the change to propagate.
* Closes the WebSocket listener and disconnects all existing clients.
* Stops emitting client count metrics.
* Deregisters from the locator, waiting for the change to propagate.
* Closes the routing listener.

To make implementing this a little easier, I've split the listeners into `SocketHandlers` and `EndpointHandlers`, and moved the health-related handlers into a separate plugin to avoid a circular dependency.

Closes #139 and #156.

@bbangert, @jrconlin r?