brotskydotcom / susen.go

A simple sudoku game.
GNU General Public License v2.0
0 stars 1 forks source link

server does not shut down gracefully #4

Closed brotskydotcom closed 8 years ago

brotskydotcom commented 9 years ago

When the server receives a SIGTERM, it simply quits hard, rather than stopping listening for new connections and waiting for the existing requests in progress to complete. It should shut down gracefully.

brotskydotcom commented 9 years ago

If you google for "golang server graceful shutdown," you will find both a lot of approaches for how to do this (including sample code) and some existing published web frameworks which make it easy. I would prefer not to go the "external framework route" yet, but I could be convinced otherwise.

brotskydotcom commented 8 years ago

Actually I am not convinced this is needed. Now that we have session persistence (#11), the better way to handle this is probably just to bring up the different server and route traffic to it and then kill the server abruptly. The one thing it might be worth doing would be to close connections when requests completed, so there wouldn't be the chance for a client to submit another request on the existing connection.

brotskydotcom commented 8 years ago

it looks like the go HTTP library Hijack mechanism allows response handlers to seize their connection and close it. So that looks like the easy way to shut down "gracefully", should that become necessary. For now, I'm going to close this as low priority.