Although JVM will translate SIGTERM and similar signals to shutdown hooks, many service shutdown scripts use a TCP port to initiate a shutdown. (e.g. Tomcat's shutdown port, Java Service Wrapper, JBoss' management interfaces, etc.)
So I thought using signals and shutdown hooks to gracefully shutdown java services is discouraged, until I found that Play! framework is managing the service lifecycle with shutdown hooks and the startup scripts generated by play dist
assumes that a signal will be sent to the JVM's 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 manner, but I would like to know how safe it is and what risks I need to consider, when I rely on SIGTERM and shutdown hooks as a primary method for service shutdown.
As long as Java service uses ShutdownHooks wisely for orderly termination, there is no problem in sending SIGTERM to JVM process. E.g. we use SIGTERM as a primary method for initiating an application shutdown in our large high-load production system (5000+ servers running 80 different Java applications).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With