Luca passed the following code. Heritrix should use
it. It loads a shutdown hook that gets called on JVM
kill (Should work with the JVMs we use, though not
guaranteed in all). We might add the writing of
reports to shutdown hook or at least a note in logs
that we'd been killed.
Hi, here are the part of code I implemented for doing a
clean shutdown of Jetty. As attachment there is the
full code of our SimpleHttpServlet...
this is in the SimpleHttpServer and will be called
during the shutdown process. The server.stop() will
call a destroy on all servlet running in the server
/**
* Stop the running server.
*
* @throws InterruptedException
*/
public synchronized void stopServer() {
if (server != null) {
try {
server.stop();
}
catch (InterruptedException e) {
System.out.println(e.toString());
}
}
}
########################################
In the constructor of SimpleHttpServlet you can add
this at the end
// register a shutdownHook for handling KILL SIGNAL
Runtime.getRuntime().addShutdownHook(new Thread() {
public void run() {
this.setName("Shutdown");
stopServer();
}
});
This will start a thread when you send a kill signal to
the virtual machine and will deal with the shutdown
#########################################
The last part is that I added a static variable to be
able to access the SimpleHttpServlet from our servlet
webapplication for calling the stopServer method from
the webinterface
Hoping that this will be usefull for you guys
Luca
Nobody/Anonymous
None
None
Public
| Field | Old Value | Date | By |
|---|---|---|---|
| status_id | Open | 2004-11-20 02:31 | stack-sf |
| close_date | - | 2004-11-20 02:31 | stack-sf |
Copyright © 2010 Geeknet, Inc. All rights reserved. Terms of Use