|
|
|
@ -263,6 +263,11 @@ public final class yacy {
|
|
|
|
|
serverSystem.openBrowser("http://localhost:" + port + "/" + browserPopUpPage, browserPopUpApplication);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// registering shutdown hook
|
|
|
|
|
serverLog.logSystem("STARTUP", "Registering Shutdown Hook");
|
|
|
|
|
Runtime run = Runtime.getRuntime();
|
|
|
|
|
run.addShutdownHook(new shutdownHookThread(Thread.currentThread(), sb));
|
|
|
|
|
|
|
|
|
|
// wait for server shutdown
|
|
|
|
|
try {
|
|
|
|
|
sb.waitForShutdown();
|
|
|
|
@ -299,7 +304,9 @@ public final class yacy {
|
|
|
|
|
ee.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
serverLog.logSystem("SHUTDOWN", "goodbye. (this is the last line)");
|
|
|
|
|
try {System.exit(0);} catch (Exception e) {} // was once stopped by de.anomic.net.ftpc$sm.checkExit(ftpc.java:1790)
|
|
|
|
|
try {
|
|
|
|
|
System.exit(0);
|
|
|
|
|
} catch (Exception e) {} // was once stopped by de.anomic.net.ftpc$sm.checkExit(ftpc.java:1790)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -328,7 +335,7 @@ public final class yacy {
|
|
|
|
|
return config;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void shutdown(String homePath) {
|
|
|
|
|
static void shutdown(String homePath) {
|
|
|
|
|
// start up
|
|
|
|
|
System.out.println(copyright);
|
|
|
|
|
System.out.println(hline);
|
|
|
|
@ -344,7 +351,7 @@ public final class yacy {
|
|
|
|
|
|
|
|
|
|
// send 'wget' to web interface
|
|
|
|
|
httpHeader requestHeader = new httpHeader();
|
|
|
|
|
requestHeader.put("Authorization", "realm=" + encodedPassword); // for http-authentify
|
|
|
|
|
requestHeader.put("REMOTE-SHUTDOWN", "realm=" + encodedPassword); // for http-authentify
|
|
|
|
|
try {
|
|
|
|
|
httpc con = httpc.getInstance("localhost", port, 10000, false);
|
|
|
|
|
httpc.response res = con.GET("Steering.html?shutdown=", requestHeader);
|
|
|
|
@ -550,3 +557,31 @@ public final class yacy {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class shutdownHookThread extends Thread
|
|
|
|
|
{
|
|
|
|
|
private plasmaSwitchboard sb = null;
|
|
|
|
|
private Thread mainThread = null;
|
|
|
|
|
|
|
|
|
|
public shutdownHookThread(Thread mainThread, plasmaSwitchboard sb) {
|
|
|
|
|
this.sb = sb;
|
|
|
|
|
this.mainThread = mainThread;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void run() {
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
if (!this.sb.isTerminated()) {
|
|
|
|
|
serverLog.logSystem("SHUTDOWN","Shutdown via shutdown hook.");
|
|
|
|
|
|
|
|
|
|
// sending the yacy main thread a shutdown signal
|
|
|
|
|
this.sb.terminate();
|
|
|
|
|
|
|
|
|
|
// waiting for the yacy thread to finish execution
|
|
|
|
|
this.mainThread.join();
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|