Change phases of WebServer start-stop and graceful shutdown lifecycles to allow other smart lifecycles to run before graceful shutdown #31714
Labels
type: enhancement
A general enhancement
Milestone
Use case: We would like to add some logic that runs on shutdown, but before the web server is shut down. To do so, we want to implement a
SmartLifecycle
with a phase that’s higher thanWebServerGracefulShutdownLifecycle
’s.Our concrete use case is that we want to have the application wait some time before actually shutting down, as in #20995. However, the proposed solution in #20995 relies on hanging the thread that sends out the context closed event. We think that using the
SmartLifecycle
interface is more appropriate. However, sinceWebServerGracefulShutdownLifecycle
’s phase is hard-coded toInteger.MAX_VALUE
, we can’t do that.Proposal: Add a property
server.shutdown-phase
to configure theSmartLifecycle
phase of allWebServerGracefulShutdownLifecycle
s. Default the value toInteger.MAX_VALUE
.Alternative: Set the hard-coded phase of
WebServerGracefulShutdownLifecycle
to something lower thanInteger.MAX_VALUE
to allow using a higher phase. This is slightly less work, but is not strictly backwards-compatible, as it may influence the order in relation to otherSmartLifecycle
s.We would be happy to provide a pull request if one of the proposals is accepted.
The text was updated successfully, but these errors were encountered: