3

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.

2 Answers 2

1

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.

2
  • Thanks towo, and how would I verify that your theory is what is happening? Do you have any ideas on how to troubleshoot that? The fix at this moment have been to just add ServerName Directive in the httpd.conf file, which has no relationship with the tomcat server.
    – Geo
    Jul 24, 2009 at 17:11
  • You could either shut down Apache independently by issuing /etc/init.d/apache2 stop at the command line, or try unceremoniously yanking the logfile out from under both processes by doing mv /var/log/apache2/error.log /var/log/apache2/error.log.test or similar. Both options would cause downtime of course, but it wouldn't be very long.
    – Ernie
    Jul 24, 2009 at 18:19
0

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .