-
Notifications
You must be signed in to change notification settings - Fork 40.8k
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
Destroy service beans after web server is down gracefully #19951
Comments
Duplicates #4657. |
@wilkinsona there are too many issues raised in #4657, and more about how to prevent accepting new requests/implement custom graceful shutdown with serverCustomizer interface for tomcat/jetty/completion all active requests, but currently waiting for active requests when sigterm is received works for Netty, doesn't it? |
The customizer approach is a way of someone implementing their own solution until Spring Boot supports it out-of-the box. #4657 is tracking the addition of that support.
I don't believe so, not out of the box anyway.
You can use a |
it's strange, have tested this in a simple way - add Thread#sleep to endpoint, call endpoint, and send sigterm to application, it doesn't destroy the webServer bean until request is finished. and it didn't work before this issue is fixed |
There's more to it than that. As described in #4657 we currently close the application context and then, at the end of that, close the web server. This means that beans that an inflight request relies upon may be destroyed while the request is still being handled. We need to do three things:
We're now going over things that have been discussed at length and are being tracked by #4657. Please subscribe to that issue for further updates. |
it's clear, thanks |
We use spring boot with embedded netty server that has graceful shutdown (that seems has been fixed in spring-projects/spring-framework#23631) and do some logic using another beans autowired into controller. When sigterm is received server waits for all in-progress requests are finished, and we have case when service is destroyed before request is finished and requests are failed due to closed resources in destroy method. and as I can see
reactorServerResourceFactory
is always destroyed last. So would be great to have ability to set up ordering betweenreactorServerResourceFactory
and custom beans. Or probably do we have a way already to customize this bean to have@DependsOn
annotation with dependency on our beans?SpringBoot version: 2.2.2.RELEASE
The text was updated successfully, but these errors were encountered: