I have 9 tomcat instances (fronted with apache and mod_jk) on a box which start with /etc/init.d/tomcatX
scripts (where X is a [1-9] number). These scripts are simple:
#!/bin/sh
### BEGIN INIT INFO
# Required-Start: mysql
### END INIT INFO
case "$1" in
'start')
/usr/local/tomcat5/bin/startup.sh
touch /var/lock/subsys/tomcat5
;;
'stop')
/usr/local/tomcat5/bin/shutdown.sh
rm -f /var/lock/subsys/tomcat5
;;
*)
echo "Usage: $0 { start | stop }"
;;
esac
exit 0
These services start on server reboot:
> chkconfig -l
...
tomcat1 0:off 1:off 2:off 3:on 4:off 5:on 6:off
tomcat2 0:off 1:off 2:off 3:on 4:off 5:on 6:off
tomcat3 0:off 1:off 2:off 3:on 4:off 5:on 6:off
tomcat4 0:off 1:off 2:off 3:on 4:off 5:on 6:off
tomcat5 0:off 1:off 2:off 3:on 4:off 5:on 6:off
tomcat6 0:off 1:off 2:off 3:on 4:off 5:on 6:off
tomcat7 0:off 1:off 2:off 3:on 4:off 5:on 6:off
tomcat8 0:off 1:off 2:off 3:on 4:off 5:on 6:off
tomcat9 0:off 1:off 2:off 3:on 4:off 5:on 6:off
The problem is that sometimes (which is pretty rare, random and non reproducible) one of the tomcats will not start because its AJP
port will already be occupied:
May 27, 2012 2:08:16 PM org.apache.jk.common.ChannelSocket init
INFO: Port busy 8015 java.net.BindException: Address already in use
May 27, 2012 2:08:16 PM org.apache.jk.common.ChannelSocket init
SEVERE: Can't find free port 8015 8015
So it'll continue the startup process and start all of its webapps but unfortunatelly they'll never be able to receive any http request.
The relevant configuration is:
<Connector port="8015" protocol="AJP/1.3" ... />
What could be the cause? There isn't anything else listening to 8015.