Graceful shutdown not working in Spring Boot App

2.6k Views Asked by At

I want to activate graceful shutdown on an existing Spring Boot (v2.3.9) app.

Initially, to test the feature out, I created a sample app and added the property server.shutdown: graceful in the application.properties. I could see the server shutting down gracefully in the logs when I kill the app.

enter image description here

Satisfied with the output, I added the same property to the existing app. However, when I kill that particular app, the shutdown doesn't happen gracefully. No logs like above are produced. This made me wonder whether the property was actually getting set so just to double down I also set it as a run-time argument -Dserver.shutdown=graceful. It didn't work even after that.

I have confirmed the Spring Boot/Tomcat versions running for the existing app and they are above the minimum required to enable this property.

The existing application has a convoluted logging structure with a variety of libraries (log4j, logback etc) in the mix. Could it be the case that the graceful shutdown is happening but due to a higher logging level, the logs don't show up? If that's the case, which property should I set/override to enable them.

1

There are 1 best solutions below

0
On

It was a logging issue indeed. A logging property deep inside the legacy code was overriding the outer log level. The shutdown works just fine.