I've been digging through the website and mailing list archives, and I'm still puzzled about how to achieve a graceful server shutdown.

By this, I mean something similar to 'apachectl graceful', where new requests are refused, but any existing requests are fully processed before the server performs shutdown functions and terminates.

My server is an HTTP server using PoCo::Server::TCP, which runs a fairly simple state machine to gather up all the information required for each request and then puts it together to construct the reply. It seems to me like implementing the graceful shutdown requires 3 parts:

1) a signal handler that sets a global "shutting down" flag

2) in my ClientInput callback, to only start the state machine if the flag is not set

3) somehow determine that all current requests have finished, and shutdown if the flag is set. This is the part that I'm stuck on.


Any help or suggestions are appreciated.


-kevin


Reply via email to