Skip to content

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

Closed
@wilkinsona

Description

@wilkinsona

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.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions