I have a server with a tomcat process binding to port 80 and a httpd processes binding to port 5000. For some reason every time any process send a SIGHUP signal to httpd process my tomcat process disappears without error or anything.
I fixed the issue on the server the following way, added an explicit ServerName directive in the httpd.conf and that fixed the issue.
I still don't understand why the SIGHUP to httpd killed the tomcat process.
NOTE 1: I replicated the kill signal with the following command:
find out what the httpd pid is.
cat /etc/httpd/run/httpd.pid
4056
then kill with a sighup signal
kill -s SIGHUP 4056
NOTE 2: We troubleshoot the issue and find that logrotate running every morning at 4am was sending a SIGHUP signal to realease the logs to be able to rotate them, thus killing tomcat as well.
I assume the tomcat is spawned by the apache.
The problem could be that when the Apache closes its logfiles, the tomcat is trying to access said logfile and when it suddenly finds it has disappeared magically, it just keels over and dies.
The other explanation would be that the Apache server is also resetting tomcat while rotating logs and reloading the configuration files (which SIGHUP initiates), and some bug or other prevents tomcat from restarting at that time.
As towo said above, this could happen if you are starting Tomcat from a PHP script running inside Apache. I ran into this and thought I'd note the following here for anyone else managing to get this far :-).
Start Tomcat with setsid, this will make sure it gets puts into its own process group, completely isolating it from any signals (including SIGHUP) you or logrotate send to Apache. Try something like:
/usr/bin/setsid $CATALINA_HOME/bin/startup.sh