Allow graceful server stop
rubencaro opened this issue · comments
Hi,
I was trying to implement an app that could stop accepting connections while still finish the ones already started (on a deploy, for instance). Then finally stop the reactor after some timeout.
Inspired by https://github.com/eventmachine/eventmachine/wiki/Code-Snippets, but knowing that there's no need to really monitor the ending of every connection, just a fair timeout. Anyway, I realized that I need the server signature to be able stop it.
That can be done several ways. One could be by just adding a small thing to https://github.com/postrank-labs/goliath/blob/master/lib/goliath/server.rb#L86:
config['server_signature'] = EM.start_server(address, port, Goliath::Connection) do |conn|
That alone would already make the server signature available as any other global on config file, allowing me to do my tricks.
I guess there's a better way to achieve that than sneaking it into config array at that point, but can you add (something like) this to goliath, please?
Thanks.
Can you send a pull request? Don't see why that couldn't be added. Although, I'd rename 'server_signature' to 'goliath.server_signature' and put the string in the constants file.