Proposal for graceful stop #54

merged 4 commits into from Feb 7, 2014


None yet
1 participant

rcrowley commented Jan 15, 2014

This pull request enables graceful stop for Tiger Tonic services (or really any service that uses tigertonic.Server instead of http.Server). Most of the work is done by tigertonic.Listener and tigertonic.Conn which account for connections with a sync.WaitGroup. Keepalives are managed by closingResponseWriter, which injects a Connection: close header into responses written after the listener is closed.

The major open question is whether this should be always-on or optional.

rcrowley added some commits Jan 15, 2014

First half of graceful stop: network accounting.
This is pretty standard and could have just been cribbed from Keith's or anyone else's examples.
Second half of graceful stop: killing keepalives.
This adds a channel and a ResponseWriter implementation to preemptively close connections (by injecting a Connection: close header) when the listener's closed.
At Brad's suggestion, combine Close and Wait.
Now Close blocks until all connections have closed.

@rcrowley rcrowley merged commit 57d20fb into master Feb 7, 2014

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