|
From: Leif M. <le...@ta...> - 2006-06-19 14:36:33
|
Prueba,
It looks like you may have already figured this out. But here is
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
[Manager] Finished.
INFO | jvm 1 | 2006/06/19 10:17:57 | Wrapper Manager: ShutdownHook
started
INFO | jvm 1 | 2006/06/19 10:17:57 | WrapperManager.stop(0) called
by thread: Wrapper-Shutdown-Hook
INFO | jvm 1 | 2006/06/19 10:17:57 | Thread, Wrapper-Shutdown-Hook,
waiting for the JVM to exit.
INFO | jvm 1 | 2006/06/19 10:18:02 | Thread, Wrapper-Shutdown-Hook,
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
complete
DEBUG | wrapper | 2006/06/19 10:18:02 | JVM process exited with a code
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
Wrapper
and not by the JVM shutting down so the JVM has not yet started the
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 that
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. This
> happens before WrapperStartStopApp starts waiting for all non-daemon threads to terminate. Perhaps there's a configuration property
> regarding this ...
>
|