Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

added restart to Status.html

borg-0300fb2742867492
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 @@
<table border="0" cellpadding="5" cellspacing="0" width="100%">
<tr valign="top" bgcolor="#DDEEDD">
<td class="TableCellLight" align="right">
- <input type="submit" name="shutdown" value="Shutdown YaCy">
+ <input type="submit" name="restart" value="Restart">
+ <input type="submit" name="shutdown" value="Shutdown">
</td>
</tr>
</table>
@@ -47,7 +48,7 @@ see the <a href="http://www.yacy.net/yacy/Installation.html#wininst">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)#
</td></tr>
@@ -98,4 +99,4 @@ You are in <i>permanent</i> mode. Attention: If you don't have a flatrate or are
#[footer]#
</body>
-</html>
+</html>
\ 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 @@
<title>YaCy '#[clientname]#': Steering</title>
#[metas]#
</head>
-<body marginheight="0" marginwidth="0" leftmargin="0" topmargin="0">
-#[header]#
-<br><br>
-<h2>Steering Receipt:</h2>
+<body marginheight="0" marginwidth="40" leftmargin="40" topmargin="0">
+
+<br><br><h2>Steering Receipt:</h2>
<p>
#(info)#
<b>No information has been submitted</b><br>
Nothing changed
+<p>You can now go back to the <a href="Settings_p.html">Settings</a> page if you want to make more changes.</p>
::
<b>Your system is not protected by a password</b><br>
Please go to the <a href="/Settings_p.html">Settings</a> page and set an administration password
::
<b>You don't have the correct access right to perform this task.</b><br>
Please log in.
+<p>You can now go back to the <a href="Settings_p.html">Settings</a> page if you want to make more changes.</p>
::
<b>Shutting down.</b>
<br>Application will terminate after working off all scheduled tasks.
::
+<b>Restart YaCy.</b><br>
+Application will terminate after working off all scheduled tasks.<br>
+Then YaCy will restart.<br>
+Wenn man nach 5 Minuten nicht auf YaCy zugreifen kann, ist ein Fehler aufgetreten.
#(/info)#
</p>
-<p>You can now go back to the <a href="Settings_p.html">Settings</a> page if you want to make more changes.</p>
-
-#[footer]#
</body>
-</html>
+</html>
\ 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; [email protected]
// 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; [email protected]
// 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)
}