Skip to content
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

Integrate web server graceful shutdown into the application context's lifecycle processing #21325

Closed
wilkinsona opened this issue May 6, 2020 · 1 comment
Assignees
Labels
type: enhancement A general enhancement
Milestone

Comments

@wilkinsona
Copy link
Member

At the moment, graceful shutdown is triggered directly by the reactive and servlet application contexts. This works well in isolation but has some drawbacks when other components want to participate in a graceful shutdown. Some of these drawbacks are described by @gnagy in #4657 (comment).

We'd like to explore reworking the management of a WebServer's lifecycle and integrating it with the application context's lifecycle processing by implementing SmartLifecycle. This would make the grace period that's currently configured via server.shutdown.grace-period more general . server.shutdown.grace-period could be replaced by a new property, spring.lifecycle.timeout-per-shutdown-phase, that maps onto the timeoutPerShutdownPhase property of DefaultLifecycleProcessor. We'd then need a new property that can be used to make the web server opt in to graceful shutdown rather than shutting down immediately as it does in 2.2. Something like server.shutdown.type that is a enum with IMMEDIATE and GRACEFUL values.

@wilkinsona wilkinsona added the type: enhancement A general enhancement label May 6, 2020
@wilkinsona wilkinsona added this to the 2.3.0 milestone May 6, 2020
@wilkinsona wilkinsona self-assigned this May 6, 2020
@sagacity
Copy link
Contributor

sagacity commented May 8, 2020

This would be great to have. We've currently added this to our applications ourselves by following the approach taken in https://github.com/SchweizerischeBundesbahnen/springboot-graceful-shutdown but it was reasonably invasive (requiring a different application class to 'wrap' the real application).

Having proper support would be great! It would be good if command-line applications (e.g. used as cronjobs) can also use the IMMEDIATE shutdown option. This would allow them to shut down cleanly while still being able to flush async logging etc. Since these types of apps don't typically need a webserver it would be very nice if this shutdown behaviour can be decoupled from the webserver part.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants