-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a hook for "before shutdown" #3327
Comments
Haven't had time to think about this, but one question:
So, you want Puma to 'wait N seconds, then drain existing connections'? Is that delay needed? Also, often 'drain' used, but there are three types. Also, see docs for
|
Yep, exactly – the pattern is effectively:
The delay is needed to allow clients and load balancers to detect that this server shouldn't receive any more traffic.
|
Hmm, isn't it better to instruct your load balancers to take out the server of the rotation when you want to restart it? (Not sure what you're using but HAProxy seems to have a |
This would be a good solution! Unfortunately, in this environment it's not an option. We're using client-side load balancers and real-time health information comes from client-side health check requests. |
Sounds cool… feel free to elaborate :) |
After some thinking, I could see another viable alternative: add a min/max drain time to
Of course! We're using Envoy as a sidecar mesh proxy in this environment – it proxies requests on both the client and server hosts. In our current configuration, health checks are an important part of the "draining" process. Please let me know if there are other specifics you're interested. |
Is your feature request related to a problem? Please describe.
In our environment, when a server is shutting down (e.g. in response to a SIGTERM) it's a common pattern to fail healthcheck requests for N seconds prior to draining existing connections and closing the listener. This gives clients (and load balancers) a chance to start sending traffic elsewhere.
At the moment, it doesn't seem that Puma supports implementing this pattern because existing shutdown hooks (e.g.
:on_stopped
event) run after the listener has been closed (link)Describe the solution you'd like
I'd like puma to support the above pattern. I think this would be possible by providing a new event or hook that fires before listeners are closed and workers are stopped. Alternatively, the existing
:on_stopped
event could be moved before the listeners are closed.I have a branch here that shows the rough shape of adding a new event.
Describe alternatives you've considered
The text was updated successfully, but these errors were encountered: