Home.

How to gracefully shutdown a Spring Boot Application

Finn Christiansen
Finn Christiansen

created at:

Did you know? Spring Boot supports Graceful Shutdown, but it’s not enabled by default!

By default, Spring Boot shuts down immediately when it receives a SIGTERM signal.

To enable Graceful Shutdown, add this to the configurtion:

server:
  shutdown: "graceful"

And to control the shutdown time, adjust the timeout:

spring:
  lifecycle:
    timeout-per-shutdown-phase: "20s"

This way, you ensure Spring Boot shuts down gracefully!

Resources

Tools

Code Snipes can be formated to an image using Chalk.ist