|
From: <TEI...@te...> - 2006-06-19 15:21:58
|
Leif, I think that's exactly what was happening. I removed the System.exit =
call and then everything started to work as expected. The CTRL +=20
C feature is interesting, will take a look into that.
Many thanks to both David and Leif
teix
----Mensaje original----
De: le...@ta...
Recibido: 19/06/2006 16:36
Para: <TEI...@te...>, <wra...@li...>
Asunto: Re: [Wrapper-user] WrapperStartStopApp stopping service=09premature=
ly?
Prueba,
It looks like you may have already figured this out. But here is=20
what is
happening. First the end of your log file and then I'll explain it to you=
.
INFO | jvm 1 | 2006/06/19 10:17:57 | [Manager (console)] Finished.
INFO | jvm 1 | 2006/06/19 10:17:57 | 34 mon 19/06/2006 10:17:57=20
[Manager] Finished.
INFO | jvm 1 | 2006/06/19 10:17:57 | Wrapper Manager: ShutdownHook=20
started
INFO | jvm 1 | 2006/06/19 10:17:57 | WrapperManager.stop(0) called=20
by thread: Wrapper-Shutdown-Hook
INFO | jvm 1 | 2006/06/19 10:17:57 | Thread, Wrapper-Shutdown-Hook,=20
waiting for the JVM to exit.
INFO | jvm 1 | 2006/06/19 10:18:02 | Thread, Wrapper-Shutdown-Hook,=20
continuing after 5 seconds.
INFO | jvm 1 | 2006/06/19 10:18:02 | Send a packet STOPPED : 0
DEBUG | wrapperp | 2006/06/19 10:18:02 | read a packet STOPPED : 0
DEBUG | wrapper | 2006/06/19 10:18:02 | JVM signalled that it was stopped=
.
INFO | jvm 1 | 2006/06/19 10:18:02 | Wrapper Manager: ShutdownHook=20
complete
DEBUG | wrapper | 2006/06/19 10:18:02 | JVM process exited with a code=20
of 0, leaving the wrapper exit code set to 0.
You see in the first few lines that after your Manager has sent the
shutdown command, and completes, the Wrapper's shutdown hook is immediately
being activated. This is most likely because your Manager class is calling
System.exit. In this mode, the original shutdown was triggered by the=20
Wrapper
and not by the JVM shutting down so the JVM has not yet started the=20
registered
shutdown hooks. It will do so now.
The Wrapper's shutdown hook is designed to block until the
WrapperListener.stop method has completed. When it calls System.exit, this
will never happen. To avoid a deadlock, the Wrapper is able to detect tha=
t
state and will only deadlock for a maximum of 5 seconds.
The JVM itself will exit as soon as all of its shutdown hooks have been
completed. It sounds like you are looping over your worker threads and
stopping each of them within a normal non daemon thread. The problem
is that none of that shutdown work is happening within the call stack of
a shutdown hook so the JVM is not going to wait for it all to complete
before shutting down.
You can solve this in one of two ways.
1) Remove the System.exit from your Manager shutdown process.
2) Add a shutdown hook to Server which loops until all of your worker
threads are stopped. That will keep the JVM up until it is safe to exit.
That would also make your Server application shutdown reliably when
it is running stand alone without the Wrapper and is killed with a CTRL-C.
I added the following note to the debug output for the next release.
The message will show up in the logs if the Wrapper's shutdown process
is initiated from within the WrapperListener.stop method by calling
System.exit.
---
System.exit appears to have been called from within the
WrapperListener.stop() method. If possible the application
should be modified to avoid this behavior.
To avoid a deadlock, this thread will only wait 5 seconds
for the application to shutdown. This may result in the
application failing to shutdown completely before the JVM
exists. Removing the offending System.exit call will
resolve this.
---
I also added a note about this to the documentation for the
WrapperStartStopApp.
Cheers,
Leif
TEI...@te... wrote:
> I think I found the problem. I was finishing both Server and Manager with=
System.exit(0) which caused the ShutdownHook to be called.=20
This=20
> happens before WrapperStartStopApp starts waiting for all non-daemon thr=
eads to terminate. Perhaps there's a configuration property=20
> regarding this ...
> =20
_______________________________________________
Wrapper-user mailing list
Wra...@li...
https://lists.sourceforge.net/lists/listinfo/wrapper-user
Prueba el correo Terra ( http://www.terra.es/correo ); Seguro, r=C3=A1pido,=
fiable.
|