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%"> <table border="0" cellpadding="5" cellspacing="0" width="100%">
<tr valign="top" bgcolor="#DDEEDD"> <tr valign="top" bgcolor="#DDEEDD">
<td class="TableCellLight" align="right"> <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> </td>
</tr> </tr>
</table> </table>
@ -47,7 +48,7 @@ see the <a href="http://www.yacy.net/yacy/Installation.html#wininst">installatio
#(peerStatistics)# #(peerStatistics)#
Unknown 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 Connects (#[juniorConnects]#|#[seniorConnects]#|#[principalConnects]#|#[disconnects]#) #[connects]# peers/hour
#(/peerStatistics)# #(/peerStatistics)#
</td></tr> </td></tr>
@ -98,4 +99,4 @@ You are in <i>permanent</i> mode. Attention: If you don't have a flatrate or are
#[footer]# #[footer]#
</body> </body>
</html> </html>

@ -4,29 +4,31 @@
<title>YaCy '#[clientname]#': Steering</title> <title>YaCy '#[clientname]#': Steering</title>
#[metas]# #[metas]#
</head> </head>
<body marginheight="0" marginwidth="0" leftmargin="0" topmargin="0"> <body marginheight="0" marginwidth="40" leftmargin="40" topmargin="0">
#[header]#
<br><br>
<h2>Steering Receipt:</h2>
<br><br><h2>Steering Receipt:</h2>
<p> <p>
#(info)# #(info)#
<b>No information has been submitted</b><br> <b>No information has been submitted</b><br>
Nothing changed 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> <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 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> <b>You don't have the correct access right to perform this task.</b><br>
Please log in. 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> <b>Shutting down.</b>
<br>Application will terminate after working off all scheduled tasks. <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)# #(/info)#
</p> </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> </body>
</html> </html>

@ -1,10 +1,13 @@
// Steering.java // Steering.java
// ----------------------- // -----------------------
// part of YaCy // part of YaCy
// (C) by Michael Peter Christen; mc@anomic.de // (C) by Michael Peter Christen; mc@anomic.de
// first published on http://www.anomic.de // first published on http://www.anomic.de
// Frankfurt, Germany, 2004, 2005 // 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 // 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 // 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 class Steering {
public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) { public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch ss) {
plasmaSwitchboard switchboard = (plasmaSwitchboard) env; if (post == null || ss == null) { return new serverObjects(); }
serverObjects prop = new serverObjects();
plasmaSwitchboard sb = (plasmaSwitchboard) ss;
serverObjects prop = new serverObjects();
prop.put("info", 0);//no information submitted prop.put("info", 0);//no information submitted
if (post == null) return prop; if (prop == null) { return prop; }
// handle access rights // handle access rights
switch (switchboard.adminAuthenticated(header)) { switch (sb.adminAuthenticated(header)) {
case 0: // wrong password given case 0: // wrong password given
try {Thread.currentThread().sleep(3000);} catch (InterruptedException e) {} // prevent brute-force try {Thread.currentThread().sleep(3000);} catch (InterruptedException e) {} // prevent brute-force
prop.put("AUTHENTICATE", "admin log-in"); // force log-in prop.put("AUTHENTICATE", "admin log-in"); // force log-in
@ -71,14 +76,22 @@ public class Steering {
case 3: // soft-authenticated for localhost only case 3: // soft-authenticated for localhost only
case 4: // hard-authenticated, all ok case 4: // hard-authenticated, all ok
} }
if (post.containsKey("shutdown")) { if (post.containsKey("shutdown")) {
switchboard.terminate(); ss.setConfig("restart", "false");
prop.put("info", 3);//shutting down 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; return prop;
} }
} }

@ -3,14 +3,13 @@
// part of YACY // part of YACY
// (C) by Michael Peter Christen; mc@anomic.de // (C) by Michael Peter Christen; mc@anomic.de
// first published on http://www.anomic.de // first published on http://www.anomic.de
//
// This file ist contributed by Alexander Schier
// //
// $LastChangedDate$ // $LastChangedDate$
// $LastChangedRevision$ // $LastChangedRevision$
// $LastChangedBy$ // $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 // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or // 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 // done inside the copyright notive above. A re-distribution must contain
// the intact and unchanged copyright notice. // the intact and unchanged copyright notice.
// Contributions and changes to the program code must be marked as such. // Contributions and changes to the program code must be marked as such.
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.BufferedWriter; import java.io.BufferedWriter;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
@ -129,7 +128,7 @@ public final class yacy {
private static final String vDATE = "@REPL_DATE@"; 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 copyright = "[ YACY Proxy v" + vString + ", build " + vDATE + " by Michael Christen / www.yacy.net ]";
private static final String hline = "-------------------------------------------------------------------------------"; private static final String hline = "-------------------------------------------------------------------------------";
/** /**
* Convert the combined versionstring into a pretty string. * Convert the combined versionstring into a pretty string.
* FIXME: Why is this so complicated? * FIXME: Why is this so complicated?
@ -172,7 +171,8 @@ public final class yacy {
*/ */
private static void startup(String homePath, long startupMemFree, long startupMemTotal) { private static void startup(String homePath, long startupMemFree, long startupMemTotal) {
long startup = System.currentTimeMillis(); long startup = System.currentTimeMillis();
String restart = "false";
try { try {
// start up // start up
System.out.println(copyright); System.out.println(copyright);
@ -216,6 +216,9 @@ public final class yacy {
final plasmaSwitchboard sb = new plasmaSwitchboard(homePath, "yacy.init", "DATA/SETTINGS/httpProxy.conf"); 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 // save information about available memory at startup time
sb.setConfig("memoryFreeAfterStartup", startupMemFree); sb.setConfig("memoryFreeAfterStartup", startupMemFree);
sb.setConfig("memoryTotalAfterStartup", startupMemTotal); sb.setConfig("memoryTotalAfterStartup", startupMemTotal);
@ -453,7 +456,8 @@ public final class yacy {
} catch (Exception e) { } catch (Exception e) {
serverLog.logSevere("MAIN CONTROL LOOP", "PANIK: " + e.getMessage(),e); serverLog.logSevere("MAIN CONTROL LOOP", "PANIK: " + e.getMessage(),e);
} }
restart = sb.getConfig("restart", "false");
// shut down // shut down
serverLog.logConfig("SHUTDOWN", "caught termination signal"); serverLog.logConfig("SHUTDOWN", "caught termination signal");
server.terminate(false); server.terminate(false);
@ -479,9 +483,27 @@ public final class yacy {
} catch (Exception ee) { } catch (Exception ee) {
serverLog.logSevere("STARTUP", "FATAL ERROR: " + ee.getMessage(),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 { try {
// if (restart) startup(homePath);
System.exit(0); System.exit(0);
} catch (Exception e) {} // was once stopped by de.anomic.net.ftpc$sm.checkExit(ftpc.java:1790) } catch (Exception e) {} // was once stopped by de.anomic.net.ftpc$sm.checkExit(ftpc.java:1790)
} }

Loading…
Cancel
Save