From fb2742867492b61168798d109ca8b68be2d22c35 Mon Sep 17 00:00:00 2001 From: borg-0300 Date: Wed, 5 Oct 2005 16:35:05 +0000 Subject: [PATCH] added restart to Status.html git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@863 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- htroot/Status.html | 7 +++-- htroot/Steering.html | 18 ++++++------ htroot/Steering.java | 39 +++++++++++++++++--------- source/de/anomic/data/listManager.java | 5 ++-- source/yacy.java | 34 ++++++++++++++++++---- 5 files changed, 70 insertions(+), 33 deletions(-) diff --git a/htroot/Status.html b/htroot/Status.html index b00222c46..dd6efdbe5 100644 --- a/htroot/Status.html +++ b/htroot/Status.html @@ -16,7 +16,8 @@
- + +
@@ -47,7 +48,7 @@ see the installatio #(peerStatistics)# Unknown :: -Uptime = #[uptime]#, Links# = #[links]#, RWIs# = #[words]#, PPM = #[pagesperminute]#, +Uptime = #[uptime]#, Links# = #[links]#, RWIs# = #[words]#, PPM = #[pagesperminute]#, Connects (#[juniorConnects]#|#[seniorConnects]#|#[principalConnects]#|#[disconnects]#) #[connects]# peers/hour #(/peerStatistics)# @@ -98,4 +99,4 @@ You are in permanent mode. Attention: If you don't have a flatrate or are #[footer]# - + \ No newline at end of file diff --git a/htroot/Steering.html b/htroot/Steering.html index 21dea2a24..af1faf18c 100644 --- a/htroot/Steering.html +++ b/htroot/Steering.html @@ -4,29 +4,31 @@ YaCy '#[clientname]#': Steering #[metas]# - -#[header]# -

-

Steering Receipt:

+ + +

Steering Receipt:

#(info)# No information has been submitted
Nothing changed +

You can now go back to the Settings page if you want to make more changes.

:: Your system is not protected by a password
Please go to the Settings page and set an administration password :: You don't have the correct access right to perform this task.
Please log in. +

You can now go back to the Settings page if you want to make more changes.

:: Shutting down.
Application will terminate after working off all scheduled tasks. :: +Restart YaCy.
+Application will terminate after working off all scheduled tasks.
+Then YaCy will restart.
+Wenn man nach 5 Minuten nicht auf YaCy zugreifen kann, ist ein Fehler aufgetreten. #(/info)#

-

You can now go back to the Settings page if you want to make more changes.

- -#[footer]# - + \ No newline at end of file diff --git a/htroot/Steering.java b/htroot/Steering.java index 95ceea47d..89fdd17a5 100644 --- a/htroot/Steering.java +++ b/htroot/Steering.java @@ -1,10 +1,13 @@ -// Steering.java +// Steering.java // ----------------------- // part of YaCy // (C) by Michael Peter Christen; mc@anomic.de // first published on http://www.anomic.de // Frankfurt, Germany, 2004, 2005 -// last major change: 18.02.2005 +// +// $LastChangedDate$ +// $LastChangedRevision$ +// $LastChangedBy$ // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -50,14 +53,16 @@ import de.anomic.server.serverSwitch; public class Steering { - public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) { - plasmaSwitchboard switchboard = (plasmaSwitchboard) env; - serverObjects prop = new serverObjects(); + public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch ss) { + if (post == null || ss == null) { return new serverObjects(); } + + plasmaSwitchboard sb = (plasmaSwitchboard) ss; + serverObjects prop = new serverObjects(); prop.put("info", 0);//no information submitted - if (post == null) return prop; + if (prop == null) { return prop; } // handle access rights - switch (switchboard.adminAuthenticated(header)) { + switch (sb.adminAuthenticated(header)) { case 0: // wrong password given try {Thread.currentThread().sleep(3000);} catch (InterruptedException e) {} // prevent brute-force prop.put("AUTHENTICATE", "admin log-in"); // force log-in @@ -71,14 +76,22 @@ public class Steering { case 3: // soft-authenticated for localhost only case 4: // hard-authenticated, all ok } - - if (post.containsKey("shutdown")) { - switchboard.terminate(); - prop.put("info", 3);//shutting down + + if (post.containsKey("shutdown")) { + ss.setConfig("restart", "false"); + sb.terminate(); + prop.put("info", 3); + return prop; + } + + if (post.containsKey("restart")) { + ss.setConfig("restart", "true"); + sb.terminate(); + prop.put("info", 4); return prop; } - return prop; + return prop; } -} +} \ No newline at end of file diff --git a/source/de/anomic/data/listManager.java b/source/de/anomic/data/listManager.java index a56f94c7c..cbc3062b4 100644 --- a/source/de/anomic/data/listManager.java +++ b/source/de/anomic/data/listManager.java @@ -3,14 +3,13 @@ // part of YACY // (C) by Michael Peter Christen; mc@anomic.de // first published on http://www.anomic.de +// +// This file ist contributed by Alexander Schier // // $LastChangedDate$ // $LastChangedRevision$ // $LastChangedBy$ // -// This file ist contributed by Alexander Schier -// last major change: 09.08.2004 -// // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or diff --git a/source/yacy.java b/source/yacy.java index d80add5c3..60f5c8aab 100644 --- a/source/yacy.java +++ b/source/yacy.java @@ -40,7 +40,6 @@ // done inside the copyright notive above. A re-distribution must contain // the intact and unchanged copyright notice. // Contributions and changes to the program code must be marked as such. - import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.ByteArrayOutputStream; @@ -129,7 +128,7 @@ public final class yacy { private static final String vDATE = "@REPL_DATE@"; private static final String copyright = "[ YACY Proxy v" + vString + ", build " + vDATE + " by Michael Christen / www.yacy.net ]"; private static final String hline = "-------------------------------------------------------------------------------"; - + /** * Convert the combined versionstring into a pretty string. * FIXME: Why is this so complicated? @@ -172,7 +171,8 @@ public final class yacy { */ private static void startup(String homePath, long startupMemFree, long startupMemTotal) { long startup = System.currentTimeMillis(); - + String restart = "false"; + try { // start up System.out.println(copyright); @@ -216,6 +216,9 @@ public final class yacy { final plasmaSwitchboard sb = new plasmaSwitchboard(homePath, "yacy.init", "DATA/SETTINGS/httpProxy.conf"); + // set default = no restart + sb.setConfig("restart", "false"); + // save information about available memory at startup time sb.setConfig("memoryFreeAfterStartup", startupMemFree); sb.setConfig("memoryTotalAfterStartup", startupMemTotal); @@ -453,7 +456,8 @@ public final class yacy { } catch (Exception e) { serverLog.logSevere("MAIN CONTROL LOOP", "PANIK: " + e.getMessage(),e); } - + restart = sb.getConfig("restart", "false"); + // shut down serverLog.logConfig("SHUTDOWN", "caught termination signal"); server.terminate(false); @@ -479,9 +483,27 @@ public final class yacy { } catch (Exception ee) { serverLog.logSevere("STARTUP", "FATAL ERROR: " + ee.getMessage(),ee); } - serverLog.logConfig("SHUTDOWN", "goodbye. (this is the last line)"); + + // restart YaCy + if (restart.equals("true")) { + serverLog.logConfig("SHUTDOWN", "RESTART..."); + long count = 0; + while (Thread.activeCount() > 1 && count <= 60) { // waiting 5 minutes + serverLog.logConfig("SHUTDOWN", "Waiting 5 seconds for " + (Thread.activeCount() - 1) + "running threads to restart YaCy"); + try { Thread.currentThread().sleep(5000); } catch (InterruptedException e) {} + count++; + } + if (count < 60) { + startupMemFree = Runtime.getRuntime().freeMemory(); // the amount of free memory in the Java Virtual Machine + startupMemTotal = Runtime.getRuntime().totalMemory(); // the total amount of memory in the Java virtual machine; may vary over time + startup(homePath, startupMemFree, startupMemTotal); + } else { + serverLog.logConfig("SHUTDOWN", "RESTART BREAK, more than 5 minutes waited to try a restart, goodbye. (this is the last line)"); + } + } else { + serverLog.logConfig("SHUTDOWN", "goodbye. (this is the last line)"); + } try { - // if (restart) startup(homePath); System.exit(0); } catch (Exception e) {} // was once stopped by de.anomic.net.ftpc$sm.checkExit(ftpc.java:1790) }