Is it safe to send SIGTERM to the JVM

Although the JVM will translate SIGTERM and similar signals to turn off hooks , many shutdown scripts use a TCP port to initiate a shutdown. (e.g. Tomcat shutdown port, Java Wrapper , JBoss management interfaces, etc.)

So, I thought that using signals and turning off hooks to gracefully disable Java services was not recommended until I discovered that Play! The framework manages the service life cycle with stop hooks , and the startup scripts generated by play dist assume that the signal will be sent to the JVM PID.

I know that signals are platform dependent and using a TCP port is a simple and extensible way to manage services in a cross-platform way, but I would like to know how secure it is and what risks I need to consider when I rely on SIGTERM on and off hooks as the main method to disable the service.

+7
java scala signals jvm shutdown-hook
source share
1 answer

As long as the Java service uses ShutdownHooks intelligently for orderly termination, there is no problem sending the SIGTERM process to the JVM. For example. we use SIGTERM as the main method to start shutting down the application in our large, high-performance system (5000+ servers running 80 different Java applications).

+1
source share

All Articles