Share

Heritrix: Internet Archive Web Crawler

Tracker: Feature Requests

5 Fix heritrix shutdown (From Luca) - ID: 1002707
Last Update: Comment added ( karl-ia )

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


Michael Stack ( stack-sf ) - 2004-08-03 16:03

5

Closed

None

Nobody/Anonymous

None

None

Public


Comments ( 2 )

Date: 2007-03-14 01:33
Sender: karl-ia


This issue is now discussed in the new JIRA tracker at
http://webteam.archive.org/jira/browse/HER-814 -- please add further
comments at that location.


Date: 2004-11-20 02:31
Sender: stack-sfProject Admin

Logged In: YES
user_id=924942

Added to Heritrix.


Attached File

No Files Currently Attached

Changes ( 2 )

Field Old Value Date By
status_id Open 2004-11-20 02:31 stack-sf
close_date - 2004-11-20 02:31 stack-sf