diff --git a/htroot/Status.html b/htroot/Status.html index 501e67abc..2e4ff3b24 100644 --- a/htroot/Status.html +++ b/htroot/Status.html @@ -13,7 +13,7 @@
- +
diff --git a/htroot/Steering.java b/htroot/Steering.java index 3eff070bd..0ad7281f7 100644 --- a/htroot/Steering.java +++ b/htroot/Steering.java @@ -46,20 +46,24 @@ // javac -classpath .:../Classes SettingsAck_p.java // if the shell's current path is HTROOT +import java.io.File; +import java.io.IOException; + import de.anomic.http.httpHeader; import de.anomic.plasma.plasmaSwitchboard; import de.anomic.server.serverObjects; import de.anomic.server.serverSwitch; +import de.anomic.server.logging.serverLog; public class Steering { 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 (prop == null) { return prop; } + + final plasmaSwitchboard sb = (plasmaSwitchboard) ss; + final serverObjects prop = new serverObjects(); + prop.put("info", 0); //no information submitted + if (prop == null) { return null; } // handle access rights if (!sb.verifyAuthentication(header, false)) { @@ -68,15 +72,23 @@ public class Steering { } if (post.containsKey("shutdown")) { - ss.setConfig("restart", "false"); sb.terminate(3000); prop.put("info", 3); return prop; } if (post.containsKey("restart")) { - ss.setConfig("restart", "true"); - sb.terminate(); + // yacy.restart erstellen (wird im startscript ausgewertet) + final File yacyRestart = new File(sb.getRootPath(), "DATA/yacy.restart"); + if (!yacyRestart.exists()) { + try { + yacyRestart.createNewFile(); + } catch (IOException e) { + serverLog.logConfig("SHUTDOWN", "ERROR: no restart !"); + e.printStackTrace(); + } + } + sb.terminate(5000); prop.put("info", 4); return prop; } diff --git a/source/yacy.java b/source/yacy.java index 07f317704..e0c22f738 100644 --- a/source/yacy.java +++ b/source/yacy.java @@ -192,10 +192,10 @@ public final class yacy { */ private static void startup(String homePath, long startupMemFree, long startupMemTotal) { long startup = System.currentTimeMillis(); - String restart = "false"; + int oldRev=0; int newRev=0; - + try { // start up System.out.println(copyright); @@ -269,9 +269,6 @@ public final class yacy { sb.setConfig("htTemplatePath", "htroot/env/templates"); sb.setConfig("parseableExt", "html,htm,txt,php,shtml,asp"); - // set default = no restart - sb.setConfig("restart", "false"); - // if we are running an SVN version, we try to detect the used svn revision now ... final Properties buildProp = new Properties(); File buildPropFile = null; @@ -450,8 +447,6 @@ public final class yacy { } catch (Exception e) { serverLog.logSevere("MAIN CONTROL LOOP", "PANIC: " + e.getMessage(),e); } - restart = sb.getConfig("restart", "false"); - // shut down serverLog.logConfig("SHUTDOWN", "caught termination signal"); server.terminate(false); @@ -478,31 +473,7 @@ public final class yacy { } catch (Exception ee) { serverLog.logSevere("STARTUP", "FATAL ERROR: " + ee.getMessage(),ee); } - - // restart YaCy - if (restart.equals("true")) { - serverLog.logConfig("SHUTDOWN", "RESTART..."); - long count = 0; - if (Thread.activeCount() > 1) { - serverLog.logConfig("SHUTDOWN", "Wait maximally 5 minutes for " + (Thread.activeCount() - 1) + " running threads to restart YaCy"); - while (Thread.activeCount() > 1 && count <= 60) { // wait 5 minutes - count++; - try { Thread.sleep(5000); } catch (InterruptedException e) {} - } - } - if (count < 60) { - System.gc(); - try { Thread.sleep(5000); } catch (InterruptedException e) {} - 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)"); -// serverLog.logConfig("SHUTDOWN", "RESTART BREAK, getAllStackTraces()\n" + Thread.getAllStackTraces()); // needs java 1.5 - } - } else { - serverLog.logConfig("SHUTDOWN", "goodbye. (this is the last line)"); - } + serverLog.logConfig("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) diff --git a/startYACY.bat b/startYACY.bat index 589fca8e6..a8dd357bb 100644 --- a/startYACY.bat +++ b/startYACY.bat @@ -22,33 +22,38 @@ Echo Generated classpath:%CLASSPATH% Echo JRE Parameters:%javacmd% Echo Priority:%priority% - Echo ****************** YaCy Web Crawler/Indexer ^& Search Engine ******************* - Echo **** (C) by Michael Peter Christen, usage granted under the GPL Version 2 **** - Echo **** USE AT YOUR OWN RISK! Project home and releases: http://yacy.net/yacy **** - Echo ** LOG of YaCy: DATA/LOG/yacy00.log (and yacy^.log) ** - Echo ** STOP YaCy: execute stopYACY.bat and wait some seconds ** - Echo ** GET HELP for YaCy: see www.yacy-websearch.net/wiki and www.yacy-forum.de ** - Echo ******************************************************************************* - Echo ^>^> YaCy started as daemon process. Administration at http://localhost:%port% ^<^< - -start "YaCy" %priority% java %javacmd% -classpath %CLASSPATH% yacy - -GoTo :END +Echo ****************** YaCy Web Crawler/Indexer ^& Search Engine ******************* +Echo **** (C) by Michael Peter Christen, usage granted under the GPL Version 2 **** +Echo **** USE AT YOUR OWN RISK! Project home and releases: http://yacy.net/yacy **** +Echo ** LOG of YaCy: DATA/LOG/yacy00.log (and yacy^.log) ** +Echo ** STOP YaCy: execute stopYACY.bat and wait some seconds ** +Echo ** GET HELP for YaCy: see www.yacy-websearch.net/wiki and www.yacy-forum.de ** +Echo ******************************************************************************* +Echo ^>^> YaCy started as daemon process. Administration at http://localhost:%port% ^<^< + +start "YaCy" %priority% /B /WAIT java %javacmd% -classpath %CLASSPATH% yacy + +if not exist DATA\yacy.restart GoTo :END +:WAIT +echo Please wait... +if exist DATA\yacy.running GoTo :WAIT +del DATA\yacy.restart +GoTo :STARTJAVA Rem This target is used to read java runtime parameters out of the yacy config file :GETSTARTOPTS for /F "tokens=1,2 delims==" %%i in (DATA\SETTINGS\httpProxy.conf) do ( - if "%%i"=="javastart_Xmx" set jmx=%%j - if "%%i"=="javastart_Xms" set jms=%%j - if "%%i"=="port" set port=%%j - if "%%i"=="javastart_priority" set priolvl=%%j + if "%%i"=="javastart_Xmx" set jmx=%%j + if "%%i"=="javastart_Xms" set jms=%%j + if "%%i"=="port" set port=%%j + if "%%i"=="javastart_priority" set priolvl=%%j ) if defined jmx set javacmd=-%jmx% if defined jms set javacmd=-%jms% %javacmd% if not defined port set port=8080 if defined priolvl ( - if %priolvl% == 20 set priority=/LOW - if %priolvl% == 10 set priority=/BELOWNORMAL + if %priolvl% == 20 set priority=/LOW + if %priolvl% == 10 set priority=/BELOWNORMAL ) GoTo :STARTJAVA