You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Shaji Thomas <Sh...@ariba.com> on 2007/11/27 23:39:44 UTC

How to make Tomcat shutdown itself if the address it is trying to bind is already in use.

I am using Tomcat 6. 

When Tomcat finds that the specified port ( http or AJP ) is already in
use, it logs a warning message and continues to run.  What we would like
is for Tomcat to shutdown when it finds that it cannot bind to the
specified address. Is there any way I can make Tomcat do this?  Or is
there a way I can catch this error within my application (which is
running under Tomcat) and initiate a shutdown? 

Any help will be greatly appreciated.

 

Thanks

Shaji

 


RE: How to make Tomcat shutdown itself if the address it is trying to bind is already in use.

Posted by Shaji Thomas <Sh...@ariba.com>.
Thank you Gregor for the links.
We are trying not to modify the Tomcat code at this point to avoid
regression testing. We decided to change our Tomcat startup scripts to
check for port issues and restart the server since this is the least
intrusive change at this point in our release cycle. 

Thanks a lot for the suggestions and links. I really appreciate it.

Shaji

-----Original Message-----
From: Gregor Schneider [mailto:rc46fi@googlemail.com] 
Sent: Thursday, November 29, 2007 3:27 AM
To: Tomcat Users List
Subject: Re: How to make Tomcat shutdown itself if the address it is
trying to bind is already in use.

Shaji,

maybe this will do the trick:

http://tomcat.apache.org/faq/security.html#8005

Cheers

Gregor
-- 
what's puzzlin' you, is the nature of my game
gpgp-fp: 79A84FA526807026795E4209D3B3FE028B3170B2
gpgp-key available @ http://pgpkeys.pca.dfn.de:11371

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: How to make Tomcat shutdown itself if the address it is trying to bind is already in use.

Posted by Gregor Schneider <rc...@googlemail.com>.
Shaji,

maybe this will do the trick:

http://tomcat.apache.org/faq/security.html#8005

Cheers

Gregor
-- 
what's puzzlin' you, is the nature of my game
gpgp-fp: 79A84FA526807026795E4209D3B3FE028B3170B2
gpgp-key available @ http://pgpkeys.pca.dfn.de:11371

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: How to make Tomcat shutdown itself if the address it is trying to bind is already in use.

Posted by Shaji Thomas <Sh...@ariba.com>.
Thank you Gregor for the suggestion. 
I was trying to see if there is a way to do this from within my
application code which is running under Tomcat. The issue is that I
don't have direct control over the scripts that start Tomcat. 

Thanks
Shaji

-----Original Message-----
From: Gregor Schneider [mailto:rc46fi@googlemail.com] 
Sent: Wednesday, November 28, 2007 8:10 AM
To: Tomcat Users List
Subject: Re: How to make Tomcat shutdown itself if the address it is
trying to bind is already in use.

if [ -z "$(netstat -lnp | grep 8080)" ]
then
    echo "Tomcat running"
    exit -1
else
    [ continue with startup-script ]
fi

do the same for port 8009 (AJP)

however, the best way would be to first check if tomcat is running
before starting it up....

remember:

a fool with a tool is still a fool...

gregor


-- 
what's puzzlin' you, is the nature of my game
gpgp-fp: 79A84FA526807026795E4209D3B3FE028B3170B2
gpgp-key available @ http://pgpkeys.pca.dfn.de:11371

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: How to make Tomcat shutdown itself if the address it is trying to bind is already in use.

Posted by Gregor Schneider <rc...@googlemail.com>.
if [ -z "$(netstat -lnp | grep 8080)" ]
then
    echo "Tomcat running"
    exit -1
else
    [ continue with startup-script ]
fi

do the same for port 8009 (AJP)

however, the best way would be to first check if tomcat is running
before starting it up....

remember:

a fool with a tool is still a fool...

gregor


-- 
what's puzzlin' you, is the nature of my game
gpgp-fp: 79A84FA526807026795E4209D3B3FE028B3170B2
gpgp-key available @ http://pgpkeys.pca.dfn.de:11371

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org