http4s / blaze

Blazing fast NIO microframework and Http Parser
Apache License 2.0
350 stars 63 forks source link

Graceful Shutdown #676

Open ChristopherDavenport opened 5 years ago

ChristopherDavenport commented 5 years ago

We currently do not support graceful shutdown in blaze.

We would ideally prefer to have a graceful shutdown, and a time till a hard shutdown. @rossabaker has been working on it and can give more specifics.

Related to http4s/http4s#751

rossabaker commented 5 years ago

http4s/http4s#2222 is prior art.

rossabaker commented 5 years ago

I don't want to block the release on this one. Demilestoning.

OngOngoing commented 4 years ago

@rossabaker hi, Do you have an update on this? or maybe could you suggest the workaround, in case I want to stop accepting new connections and keep process all the unfinished requests. 😄

rossabaker commented 4 years ago

I have found it extremely difficult to implement this in blaze. I would still like it to have that feature, but am not currently actively working on it.

tomasherman commented 4 years ago

guys, how does this relate to this part of docs:

As a convenience, cats-effect provides an cats.effect.IOApp trait with an abstract run method that returns a IO[ExitCode]. An IOApp runs the process and adds a JVM shutdown hook to interrupt the infinite process and gracefully shut down your server when a SIGTERM is received.

from here: https://http4s.org/v0.21/service/

is the graceful shutdown implemented or not? :)

rossabaker commented 4 years ago

I'd say it's a misleading statement, because it's implementation dependent. IOApp will await the finalizers of your composed resource, but the blaze-server does not yet await the drainage of all active connections in its finalizer.

Furthermore, blocking the finalizer as connections drain is not necessarily what a backend should do, because a lot of users may want to wait up to a fixed time, and then aggressively shut down the server.

tomasherman commented 4 years ago

i see ... do you know if other implementations do that? jetty for example?