On Sat, Feb 23, 2013 at 11:15 AM, Coda Hale <
coda...@gmail.com> wrote:
> The ideal shutdown sequence is:
>
> 1. The server socket is closed.
> 2. The server thread pool quiesces, handling all in-flight requests.
> 3. All managed objects are notified that the system is shutting down.
>
> This is what Dropwizard does.
Yes, and this works well for services that are completely driven by
client requests (which is pretty much any service I have written
before one I am currently working on).
I assume that shutdown period limits maximum time between steps 1 and
3, to limit maximum time it takes for system to shut down, regardless
of possible slow clients and such.
In my case services also collaborate with each other, mostly to
synchronize data. Minimally I just need notification from step (1), to
start shutdown active parts of services (stop sending synchronization
requests; receivers are already stopped by DW). Otherwise it is likely
to have in-flight out-going requests, as they are not drained, causing
spurious errors when incoming requests are exhausted.
An additional useful thing with this is that service itself can also
be aware of the shutdown process, so that logging of problems can be
changed to suppress problems that are likely caused by shutdown
process.
I hope this makes more sense.
I can look at the code, and perhaps one possibility is to just
register alternate shutdown hooks; these should be called (AFAIK) in
parallel, in arbitrary order. If so there is no need for specific
support. But I wanted to check if something might already exists for
this.
-+ Tatu +-