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.