0

We are developing a spring boot and spring batch application using gradle. We will be deploying this application on a linux environment.

we are using distTar to generate a tar using application plugin.

We register a shutdown hook to close the context and do some other stuff before the application is being shutdown.

When we run the application from eclipse as a Spring Boot Application, the shutdown hook is executing, but when we run it on linux with the startup script generated by gradle plugin, the shutdown hook is not executing.

How do we deploy spring boot applications in production linux environments? How to make sure that the shutdown hook is being executed.

When I say its not executing, when I do a CTRC+C or a kill -9 , the statements in the shutdown hook and the methods annotated with @PreDestroy methods are not printed/executed.

Looking for options to gracefully shutdown the application by closing the context.

Sanjeev
  • 119
  • 4
  • 18

1 Answers1

0

kill -s TERM PID this worked and the shutdown hook got executed.

More options and information are available in the below articles/questions on stackoverflow : How to stop java process gracefully? How to shutdown a Spring Boot Application in a correct way? How to shutdown a Spring Boot Application in a correct way?

Sanjeev
  • 119
  • 4
  • 18