Re: The question of automatic restart Tomcat

2010-04-13 Thread Christopher Schultz
-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



Re: The question of automatic restart Tomcat

2010-04-13 Thread David kerber

On 4/13/2010 7:18 AM, Mirgorodskiy Eugene wrote:

Good afternoon.
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.
If such service I will is it is very grateful if you send me the reference to 
the documentation on
adjustment of this service, or simply tell as it is called.



Copy

  Good afternoon.
I apologize if this topic is described in the documentation Tomcat, I do not 
understand English.
Could you answer me is there in tomcat 6.0.X
service that would automatically starts Tomcat, at the conclusion of his work 
as a result of errors
or malfunction of the software.
If this service is going to be very grateful if you send me a link to
the documentation on configuring this service, or just tell it s called.


In windows, you can set services to automatically restart if they fail. 
 That is done from the services manager in Administrative Tools.



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



Re: The question of automatic restart Tomcat

2010-04-13 Thread Jon Brisbin
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



Re: The question of automatic restart Tomcat

2010-04-13 Thread Gregor Schneider
On Tue, Apr 13, 2010 at 7:46 PM, Jon Brisbin
jon.bris...@npcinternational.com wrote:
 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

I'm not aware of that option within my standard sun jdk 1.6.x - what
Java-version are you running offering this really useful feature?

Cheers

Gregor
-- 
just because you're paranoid, don't mean they're not after you...
gpgp-fp: 79A84FA526807026795E4209D3B3FE028B3170B2
gpgp-key available
@ http://pgpkeys.pca.dfn.de:11371
@ http://pgp.mit.edu:11371/
skype:rc46fi

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



Re: The question of automatic restart Tomcat

2010-04-13 Thread Bob Hall
Gregor,

--- On Tue, 4/13/10 at 1:19 PM, Gregor Schneider rc4...@googlemail.com wrote:

 
  -XX:OnOutOfMemoryError=/usr/sbin/restart_tcserver
 
 I'm not aware of that option within my standard sun jdk
 1.6.x - what
 Java-version are you running offering this really useful
 feature?
 

I wasn't aware of it either.

From http://java.sun.com/javase/technologies/hotspot/vmoptions.jsp

-XX:OnOutOfMemoryError=cmd args;cmd args

Run user-defined commands when an OutOfMemoryError is first thrown. (Introduced 
in 1.4.2 update 12, 6)

- Bob




  

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



Re: The question of automatic restart Tomcat

2010-04-13 Thread Thad Humphries
This looks to be a feature of Java HotSpot, and available since v1.4:
http://java.sun.com/javase/technologies/hotspot/vmoptions.jsp

On Tue, Apr 13, 2010 at 4:19 PM, Gregor Schneider rc4...@googlemail.comwrote:

 On Tue, Apr 13, 2010 at 7:46 PM, Jon Brisbin
 jon.bris...@npcinternational.com wrote:
  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
 
 I'm not aware of that option within my standard sun jdk 1.6.x - what
 Java-version are you running offering this really useful feature?

 Cheers

 Gregor


-- 
Hell hath no limits, nor is circumscrib'd In one self-place; but where we
are is hell, And where hell is, there must we ever be --Christopher
Marlowe, 'Doctor Faustus' (v, 121-24)


Re: The question of automatic restart Tomcat

2010-04-13 Thread Jon Brisbin
comments below...

On Apr 13, 2010, at 3:40 PM, Bob Hall wrote:

 Gregor,
 
 --- On Tue, 4/13/10 at 1:19 PM, Gregor Schneider rc4...@googlemail.com 
 wrote:
 
 
 -XX:OnOutOfMemoryError=/usr/sbin/restart_tcserver
 
 I'm not aware of that option within my standard sun jdk
 1.6.x - what
 Java-version are you running offering this really useful
 feature?
 
 
 I wasn't aware of it either.
 
 From http://java.sun.com/javase/technologies/hotspot/vmoptions.jsp
 
 -XX:OnOutOfMemoryError=cmd args;cmd args
 
 Run user-defined commands when an OutOfMemoryError is first thrown. 
 (Introduced in 1.4.2 update 12, 6)

There's also:

-XX:OnError=cmd args;cmd args Run user-defined commands on fatal 
error. (Introduced in 1.4.2 update 9.)


Jon Brisbin
Portal Webmaster
NPC International, Inc.


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