added restart to Status.html

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@863 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
borg-0300 20 years ago
parent 0dcfc25d98
commit fb27428674

@ -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>

@ -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>

@ -4,7 +4,10 @@
// (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
@ -72,13 +77,21 @@ public class Steering {
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;
}
}

@ -4,13 +4,12 @@
// (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

@ -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;
@ -172,6 +171,7 @@ public final class yacy {
*/
private static void startup(String homePath, long startupMemFree, long startupMemTotal) {
long startup = System.currentTimeMillis();
String restart = "false";
try {
// start up
@ -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,6 +456,7 @@ 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");
@ -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)
}

Loading…
Cancel
Save