We use automatic restarts on OutOfMemory errors and it works fantastically. I 
don't do it the way described here, though. I use the JVM's 
-XX:OnOutOfMemoryError option. I add the following to CATALINA_OPTS:

-XX:OnOutOfMemoryError=/usr/sbin/restart_tcserver

...which restarts tcServer whenever an OOME occurs. Unfortunately, it doesn't 
produce a stacktrace (it calls your script instead). But that's okay in my 
case. I just want to make sure the server gets restarted.

We had one of these a while back, so I know it works fine (the restart script 
also sends me an email--including "top" output--letting me know what happened).

Thanks!

Jon Brisbin
Portal Webmaster
NPC International, Inc.

On Apr 13, 2010, at 11:37 AM, Christopher Schultz wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Eugene,
> 
> On 4/13/2010 7:18 AM, Mirgorodskiy Eugene wrote:
>> I apologise if this theme described in documentation Tomcat, I badly
>> understand English language.
>> 
>> Whether you could not answer me is in tomcat 6.0.X Service which
>> automatically would start Tomcat, at end of its work as a result of
>> an error or failure in software work.
> 
> Tomcat does not provide this service. There may be such services
> available elsewhere, but I am unaware of them.
> 
> You may be able to create your own, something like this:
> 
> #!/bin/sh
> 
> CATALINA_HOME=/opt/tomcat6
> CHECK_INTERVAL=30s
> RESTART_INTERVAL=10s
> 
> while true ; do
>  # Start TC in background
>  "${CATALINA_HOME}/bin/catalina.sh" start
> 
>  # Repeatedly check stdout for errors
>  while true ; do
>    sleep ${CHECK_INTERVAL}
>    grep OutOfMemoryError "${CATALINA_HOME}/logs/catalina.out"
> 
>    result = $?
>    if [ "0" == "${result}" ] ; then
>      break
>    fi
>  done
> 
>  # Stop TC
>  "${CATALINA_HOME}/bin/catalina.sh" stop
>  sleep ${RESTART_INTERVAL}
> done
> 
> This will run Tomcat forever and restart it if any OutOfMemoryError
> messages are emitted to logs/catalina.out.
> 
> You can certainly customize this to meet whatever other needs you may
> have. You can even have your webapp dump something into stdout (or some
> other file) and check that, too.
> 
> Hope that helps,
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
> 
> iEYEARECAAYFAkvEndIACgkQ9CaO5/Lv0PDORQCfcTUbMHXMqiNFLPvRl7Spfnzg
> erAAoI1r5JnHFLVpmg0PereR4yBBzTAU
> =/1/r
> -----END PGP SIGNATURE-----
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to