You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Walker Chris <wa...@dc-link.co.uk> on 2003/09/15 11:38:44 UTC

Apache/Tomcat/MySQL Startup Sequence on Linux

Hi,

I'm having problems coordinating the startup scripts for Apache, Tomcat
(connected via mod_webapp) and MySQL.  The situation seems to be this:

- mod_webapp requires Tomcat to be already running when httpd starts

- the Tomcat application contains a connection pool that requires MySQL to
be running when Tomcat starts (this is a crap architecture, but I havn't
time to change it)

I can execute the startup scripts manually in the sequence
MySQL/Tomcat/Apache, and everything is fine.  But when they are executed at
system boot it doesn't work.  The httpd log contains a "web application not
found" message, and pages from the application are not available.

I've renamed the startup scripts so that the sequence is correct, but it
still doesn't work.  My guess is that most of the Tomcat startup forks, so
that the httpd startup is invoked before it has completed.

I can think of two very klugey workarounds: 

- call httpd restart at the end of the Tomcat startup - what will this do if
the "real" httpd script is still executing?

- make the httpd script sleep for a while before it does anything - but
there's no way to guarantee it will sleep long enough

Alternatively I could add code to the httpd script to see if Tomcat has
completed its startup.  But I don't know for sure how I would tell, and I'd
rather avoid this sort of hack if there's a proper way to do it.

Chris Walker

Re: Apache/Tomcat/MySQL Startup Sequence on Linux

Posted by Tim Funk <fu...@joedog.org>.
Don't use mod_webapp. Use jk or jk2. Webapp is unsupported.

jk, jk2 allow for either side to go down and all is still ok when it comes 
back up

-Tim

Walker Chris wrote:

> Hi,
> 
> I'm having problems coordinating the startup scripts for Apache, Tomcat
> (connected via mod_webapp) and MySQL.  The situation seems to be this:
> 
> - mod_webapp requires Tomcat to be already running when httpd starts
> 
> - the Tomcat application contains a connection pool that requires MySQL to
> be running when Tomcat starts (this is a crap architecture, but I havn't
> time to change it)
> 
> I can execute the startup scripts manually in the sequence
> MySQL/Tomcat/Apache, and everything is fine.  But when they are executed at
> system boot it doesn't work.  The httpd log contains a "web application not
> found" message, and pages from the application are not available.
> 
> I've renamed the startup scripts so that the sequence is correct, but it
> still doesn't work.  My guess is that most of the Tomcat startup forks, so
> that the httpd startup is invoked before it has completed.
> 
> I can think of two very klugey workarounds: 
> 
> - call httpd restart at the end of the Tomcat startup - what will this do if
> the "real" httpd script is still executing?
> 
> - make the httpd script sleep for a while before it does anything - but
> there's no way to guarantee it will sleep long enough
> 
> Alternatively I could add code to the httpd script to see if Tomcat has
> completed its startup.  But I don't know for sure how I would tell, and I'd
> rather avoid this sort of hack if there's a proper way to do it.
> 
> Chris Walker
>  


RE: Apache/Tomcat/MySQL Startup Sequence on Linux

Posted by Dana Bourgeois <em...@netgods.us>.
Umm... you didn't get a response to your initial question about starting
things in the right order so perhaps I can help.

Sometimes it can be as easy as taking out background commands (ampersand)
from the scripts to force them to wait until the app completes its startup.


If that doesn't work, and I've seen plenty of cases where it doesn't, I'd
write a new script (wrapper) that calls the existing set of startup scripts
in proper order and waits for an indication that the application is up and
ready.  I haven't written such a thing for any of these applications but
MySQL, for example, should respond properly to an ODBC connection when it is
up.  Apache should respond to a GET.  Try scripting those in an until loop
after calling the regular startup script in your new SuperScript.  

Another technique is to loop in your wrapper watching either the regular
startup script to end (not likely to help with this problem), watching the
process list for an indication that startup is complete or watching the
messages log.  Sendmail, for example, is listed in the process list as
"accepting connections" when it is ready.  Apache should have the proper
number of child processes idling when it is ready.  

Your new Superscript should go in the proper spot for booting and the
regular scripts should be removed.  

Hope this helps.


Dana Bourgeois


> -----Original Message-----
> From: Walker Chris [mailto:walkerc@dc-link.co.uk] 
> Sent: Monday, September 15, 2003 2:39 AM
> To: 'Tomcat Users List'
> Subject: Apache/Tomcat/MySQL Startup Sequence on Linux
> 
> 
> Hi,
> 
> I'm having problems coordinating the startup scripts for 
> Apache, Tomcat (connected via mod_webapp) and MySQL.  The 
> situation seems to be this:
> 
> - mod_webapp requires Tomcat to be already running when httpd starts
> 
> - the Tomcat application contains a connection pool that 
> requires MySQL to be running when Tomcat starts (this is a 
> crap architecture, but I havn't time to change it)
> 
> I can execute the startup scripts manually in the sequence 
> MySQL/Tomcat/Apache, and everything is fine.  But when they 
> are executed at system boot it doesn't work.  The httpd log 
> contains a "web application not found" message, and pages 
> from the application are not available.
> 
> I've renamed the startup scripts so that the sequence is 
> correct, but it still doesn't work.  My guess is that most of 
> the Tomcat startup forks, so that the httpd startup is 
> invoked before it has completed.
> 
> I can think of two very klugey workarounds: 
> 
> - call httpd restart at the end of the Tomcat startup - what 
> will this do if the "real" httpd script is still executing?
> 
> - make the httpd script sleep for a while before it does 
> anything - but there's no way to guarantee it will sleep long enough
> 
> Alternatively I could add code to the httpd script to see if 
> Tomcat has completed its startup.  But I don't know for sure 
> how I would tell, and I'd rather avoid this sort of hack if 
> there's a proper way to do it.
> 
> Chris Walker
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>