2

I am working on a Discord Bot, that uses the Spring Boot Framework. I was thinking for the occasional automated and manual reboots and maintenance, that once it receives a kill signal, it send perform an action, such as notifying uses of it shutting down, before it having the application killed.

So how can I handle a KILL sig in Java. I use a Raspbin OS on a Raspberry Pi atm, but that may change to an Amazon Linux OS in the near future.

needoriginalname
  • 703
  • 3
  • 9
  • 27
  • 1
    Possible duplicate of [How to gracefully handle the SIGKILL signal in Java](https://stackoverflow.com/questions/2541597/how-to-gracefully-handle-the-sigkill-signal-in-java) – CryptoFool Apr 13 '19 at 05:39
  • 2
    Spring Boot already handles that for you. Just add a PreDestroy method to your bean, and it will be called before shutdown. And it's documented: https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-features-application-exit – JB Nizet Apr 13 '19 at 05:51

0 Answers0