From 1fa4feb8e657a9926e1c7c5304821fe0b2c662a7 Mon Sep 17 00:00:00 2001 From: orbiter Date: Thu, 28 Jun 2007 20:36:15 +0000 Subject: [PATCH] added restart button. should work on linux and mac, but was only tested on mac should of course work on windows as before git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@3934 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- build.properties | 2 +- htroot/Status.html | 5 +- htroot/Status.java | 57 ++++++----- htroot/Steering.java | 30 ++++-- restart.sh | 15 +++ source/de/anomic/yacy/yacyVersion.java | 9 +- startYACY_with_Updater.bat | 67 ------------- startYACY_with_Updater.command | 11 -- startYACY_with_Updater.sh | 134 ------------------------- 9 files changed, 79 insertions(+), 251 deletions(-) create mode 100755 restart.sh delete mode 100644 startYACY_with_Updater.bat delete mode 100644 startYACY_with_Updater.command delete mode 100644 startYACY_with_Updater.sh diff --git a/build.properties b/build.properties index 1b5436f4f..4ceb86f73 100644 --- a/build.properties +++ b/build.properties @@ -3,7 +3,7 @@ javacSource=1.4 javacTarget=1.4 # Release Configuration -releaseVersion=0.533 +releaseVersion=0.534 releaseFile=yacy_v${releaseVersion}_${DSTAMP}_${releaseNr}.tar.gz proReleaseFile=yacy_pro_v${releaseVersion}_${DSTAMP}_${releaseNr}.tar.gz releaseFileParentDir=yacy diff --git a/htroot/Status.html b/htroot/Status.html index 74afeceff..2f57d7a6a 100644 --- a/htroot/Status.html +++ b/htroot/Status.html @@ -136,11 +136,10 @@
- #(restartEnabled)#:: #(/restartEnabled)# +
+ #(candeploy)#::
System Update @@ -177,6 +177,7 @@
+ #(/candeploy)#
Public System Properties diff --git a/htroot/Status.java b/htroot/Status.java index 9a537a15b..abce5fe74 100644 --- a/htroot/Status.java +++ b/htroot/Status.java @@ -63,6 +63,7 @@ import de.anomic.server.serverDate; import de.anomic.server.serverMemory; import de.anomic.server.serverObjects; import de.anomic.server.serverSwitch; +import de.anomic.server.serverSystem; import de.anomic.yacy.yacyCore; import de.anomic.yacy.yacySeed; import de.anomic.yacy.yacyVersion; @@ -154,11 +155,7 @@ public class Status { } else { prop.put("protection", 1); // protected } - - // if running on Windows or with updater/wrapper enable restart button - if (System.getProperty("os.name").toLowerCase().startsWith("win")) { - prop.put("restartEnabled", 1); } - + // version information prop.put("versionpp", yacy.combined2prettyVersion(sb.getConfig("version","0.1"))); @@ -166,25 +163,31 @@ public class Status { // cut off the SVN Rev in the Version try {thisVersion = Math.round(thisVersion*1000.0)/1000.0;} catch (NumberFormatException e) {} - // list downloaded releases - yacyVersion release, dflt; - String[] downloaded = sb.releasePath.list(); - TreeSet downloadedreleases = new TreeSet(); - for (int j = 0; j < downloaded.length; j++) { - release = (yacyVersion) new yacyVersion(downloaded[j]); - downloadedreleases.add(release); - } - dflt = (downloadedreleases.size() == 0) ? null : (yacyVersion) downloadedreleases.last(); + if (serverSystem.canExecUnix) { + // we can deploy a new system with (i.e.) + // cd DATA/RELEASE;tar xfz $1;cp -Rf yacy/* ../../;rm -Rf yacy + + prop.put("candeploy", 1); + + // list downloaded releases + yacyVersion release, dflt; + String[] downloaded = sb.releasePath.list(); + TreeSet downloadedreleases = new TreeSet(); + for (int j = 0; j < downloaded.length; j++) { + release = (yacyVersion) new yacyVersion(downloaded[j]); + downloadedreleases.add(release); + } + dflt = (downloadedreleases.size() == 0) ? null : (yacyVersion) downloadedreleases.last(); Iterator i = downloadedreleases.iterator(); int relcount = 0; while (i.hasNext()) { release = (yacyVersion) i.next(); - prop.put("downloadedreleases_" + relcount + "_name", (release.proRelease ? "pro" : "standard") + "/" + ((release.mainRelease) ? "main" : "dev") + " " + release.releaseNr + "/" + release.svn); - prop.put("downloadedreleases_" + relcount + "_file", release.name); - prop.put("downloadedreleases_" + relcount + "_selected", (release == dflt) ? 1 : 0); + prop.put("candeploy_downloadedreleases_" + relcount + "_name", (release.proRelease ? "pro" : "standard") + "/" + ((release.mainRelease) ? "main" : "dev") + " " + release.releaseNr + "/" + release.svn); + prop.put("candeploy_downloadedreleases_" + relcount + "_file", release.name); + prop.put("candeploy_downloadedreleases_" + relcount + "_selected", (release == dflt) ? 1 : 0); relcount++; } - prop.put("downloadedreleases", relcount); + prop.put("candeploy_downloadedreleases", relcount); // list remotely available releases TreeSet[] releasess = yacyVersion.allReleases(); // {0=promain, 1=prodev, 2=stdmain, 3=stddev} @@ -195,9 +198,9 @@ public class Status { i = releases.iterator(); while (i.hasNext()) { release = (yacyVersion) i.next(); - prop.put("availreleases_" + relcount + "_name", (release.proRelease ? "pro" : "standard") + "/" + ((release.mainRelease) ? "main" : "dev") + " " + release.releaseNr + "/" + release.svn); - prop.put("availreleases_" + relcount + "_url", release.url.toString()); - prop.put("availreleases_" + relcount + "_selected", 0); + prop.put("candeploy_availreleases_" + relcount + "_name", (release.proRelease ? "pro" : "standard") + "/" + ((release.mainRelease) ? "main" : "dev") + " " + release.releaseNr + "/" + release.svn); + prop.put("candeploy_availreleases_" + relcount + "_url", release.url.toString()); + prop.put("candeploy_availreleases_" + relcount + "_selected", 0); relcount++; } // dev @@ -207,13 +210,15 @@ public class Status { i = releases.iterator(); while (i.hasNext()) { release = (yacyVersion) i.next(); - prop.put("availreleases_" + relcount + "_name", (release.proRelease ? "pro" : "standard") + "/" + ((release.mainRelease) ? "main" : "dev") + " " + release.releaseNr + "/" + release.svn); - prop.put("availreleases_" + relcount + "_url", release.url.toString()); - prop.put("availreleases_" + relcount + "_selected", (release == dflt) ? 1 : 0); + prop.put("candeploy_availreleases_" + relcount + "_name", (release.proRelease ? "pro" : "standard") + "/" + ((release.mainRelease) ? "main" : "dev") + " " + release.releaseNr + "/" + release.svn); + prop.put("candeploy_availreleases_" + relcount + "_url", release.url.toString()); + prop.put("candeploy_availreleases_" + relcount + "_selected", (release == dflt) ? 1 : 0); relcount++; } - prop.put("availreleases", relcount); - + prop.put("candeploy_availreleases", relcount); + } else { + prop.put("candeploy", 0); + } /* if ((adminaccess) && (yacyVersion.latestRelease >= (thisVersion+0.01))) { // only new Versions(not new SVN) diff --git a/htroot/Steering.java b/htroot/Steering.java index 4929e83a7..1dd902926 100644 --- a/htroot/Steering.java +++ b/htroot/Steering.java @@ -46,7 +46,6 @@ // javac -classpath .:../Classes SettingsAck_p.java // if the shell's current path is HTROOT - import java.io.File; import java.io.IOException; @@ -55,6 +54,7 @@ import de.anomic.plasma.plasmaSwitchboard; import de.anomic.server.serverObjects; import de.anomic.server.serverSwitch; import de.anomic.server.logging.serverLog; +import de.anomic.server.serverSystem; public class Steering { @@ -80,18 +80,32 @@ public class Steering { if (post.containsKey("restart")) { if (System.getProperty("os.name").toLowerCase().startsWith("win")) { - // create yacy.restart file which is used in Windows startscript - final File yacyRestart = new File(sb.getRootPath(), "DATA/yacy.restart"); - if (!yacyRestart.exists()) { + // create yacy.restart file which is used in Windows startscript + 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(); + } + } + } else if (serverSystem.canExecUnix) { + // start a re-start daemon try { - yacyRestart.createNewFile(); + /*Process p =*/ Runtime.getRuntime().exec("/bin/sh " + sb.getRootPath() + "/restart.sh &"); + /* + BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream())); + PrintWriter out = new PrintWriter(System.out); + String text; + while ((text = in.readLine()) != null) { + out.println(text); out.flush(); + } + */ } catch (IOException e) { - serverLog.logConfig("SHUTDOWN", "ERROR: no restart !"); e.printStackTrace(); } } - } - sb.terminate(5000); prop.put("info", 4); diff --git a/restart.sh b/restart.sh new file mode 100755 index 000000000..a3f07548a --- /dev/null +++ b/restart.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# this is the restart process script that is started from YaCy +# in case that YaCy is terminated with the restart option + +# navigate into the own directory path +cd `dirname $0` + +# waiting for shutdown +while [ -e DATA/yacy.running ]; do +sleep 1 +done + +# shutdown complete, start up yacy +./startYaCy.sh diff --git a/source/de/anomic/yacy/yacyVersion.java b/source/de/anomic/yacy/yacyVersion.java index 64f0b1124..519ab78b2 100644 --- a/source/de/anomic/yacy/yacyVersion.java +++ b/source/de/anomic/yacy/yacyVersion.java @@ -168,8 +168,8 @@ public final class yacyVersion implements Comparator, Comparable { TreeSet s; for (int i = 0; i < 4; i++) { s = new TreeSet(); - if (b[i] != null) s.addAll((TreeSet) b[i]); - if (a[i] != null) s.addAll((TreeSet) a[i]); + if ((b != null) && (b[i] != null)) s.addAll((TreeSet) b[i]); + if ((a != null) && (a[i] != null)) s.addAll((TreeSet) a[i]); r[i] = s; } return r; @@ -263,4 +263,9 @@ public final class yacyVersion implements Comparator, Comparable { // save file serverFileUtils.write(file, new File(storagePath, release.url.getFileName())); } + + public static void writeDeployScript(String release) { + byte[] script = ("tar xfz " + release + ";cp -Rf yacy/* ../../;rm -Rf yacy;cd ../../;startYACY.sh").getBytes(); + + } } diff --git a/startYACY_with_Updater.bat b/startYACY_with_Updater.bat deleted file mode 100644 index dbae693e7..000000000 --- a/startYACY_with_Updater.bat +++ /dev/null @@ -1,67 +0,0 @@ -@Echo Off -title YaCy - -If %1.==CPGEN. GoTo :CPGEN - -Rem Generating the proper classpath unsing loops and labels -Set CLASSPATH=classes;htroot;lib/updater/YaCyUpdater_r3.jar -For %%X in (lib/*.jar) Do Call %0 CPGEN lib\%%X -For %%X in (libx/*.jar) Do Call %0 CPGEN libx\%%X - -REM Please change the "javastart" settings in the web-interface "Basic Configuration" -> "Advanced" -set jmx= -set jms= -set javacmd=-Xmx64m -Xms10m -set priolvl=0 -set priority=/NORMAL -if exist DATA\SETTINGS\httpProxy.conf GoTo :GETSTARTOPTS - -:STARTJAVA -Rem Starting YaCy -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% /B /WAIT java %javacmd% -classpath %CLASSPATH% YaCyUpdater - -if not exist DATA\yacy.restart GoTo :END -:WAIT -echo Please wait... -REM 'sleep' five seconds -ping localhost -n 5 >NUL -if exist DATA\yacy.running GoTo :WAIT -del DATA\yacy.restart - -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 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 -) - -GoTo :STARTJAVA - -Rem This target is used to concatenate the classpath parts -:CPGEN -Set CLASSPATH=%CLASSPATH%;%2 - -Rem Target needed to jump to the end of the file -:END diff --git a/startYACY_with_Updater.command b/startYACY_with_Updater.command deleted file mode 100644 index 540eb55f8..000000000 --- a/startYACY_with_Updater.command +++ /dev/null @@ -1,11 +0,0 @@ -cd `dirname $0` -./startYACY_with_experimental_Updater.sh & -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.sh 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:8080 <<" -echo " You can close this window now, this will NOT shut down your YaCy peer." diff --git a/startYACY_with_Updater.sh b/startYACY_with_Updater.sh deleted file mode 100644 index efedaadb1..000000000 --- a/startYACY_with_Updater.sh +++ /dev/null @@ -1,134 +0,0 @@ -#!/bin/sh -JAVA="`which java`" -LOGFILE="yacy.log" - -#check if OS is Sun Solaris or one of the OpenSolaris distributions and use different version of id if necessary -if [ "`uname`" = "SunOS" ] -then - # only this version of id supports the parameter -u - ID="/usr/xpg4/bin/id" -else - # regular id for any other case (especially Linux and OSX) - ID="id" -fi - -if [ "`$ID -u`" -eq 0 ] -then - echo - echo "For security reasons you should not run this script as root!" - echo - exit 1 -elif [ ! -x "$JAVA" ] -then - echo "The java command is not executable." - echo "Either you have not installed java or it is not in your PATH" - #Cron supports setting the path in - #echo "Has this script been invoked by CRON?" - #echo "if so, please set PATH in the crontab, or set the correct path in the variable in this script." - exit 1 -fi - -#startup YaCy -cd "`dirname $0`" - -options="`getopt -n YaCy -o d,l,p,t -- $@`" -if [ $? -ne 0 ];then - exit 1; -fi - -isparameter=0; #options or parameter part of getopts? -parameter="" #parameters will be collected here - -LOGGING=0 -DEBUG=0 -PRINTONLY=0 -TAILLOG=0 -for option in $options;do - if [ $isparameter -ne 1 ];then #option - if [ "$option" = "-l" ];then - LOGGING=1 - if [ $DEBUG -eq 1 ];then - echo "can not combine -l and -d" - exit 1; - fi - elif [ "$option" = "-d" ];then - DEBUG=1 - if [ $LOGGING -eq 1 ];then - echo "can not combine -l and -d" - exit 1; - fi - elif [ "$option" = "-p" ];then - PRINTONLY=1 - elif [ "$option" = "-t" ];then - TAILLOG=1 - fi #which option - else #parameter - if [ x$option = "--" ];then #option / parameter seperator - isparameter=1; - continue - else - parameter="$parameter $option" - fi - fi #parameter or option? -done - -#echo $options;exit 0 #DEBUG for getopts - -#get javastart args -java_args="" -if [ -f DATA/SETTINGS/httpProxy.conf ] -then - # startup memory - for i in Xmx Xms; do - j=`grep javastart_$i DATA/SETTINGS/httpProxy.conf`; - j="${j#javastart_$i=}"; - if [ -n $j ]; then JAVA_ARGS="-$j $JAVA_ARGS"; fi; - done - - # Priority - j=`grep javastart_priority DATA/SETTINGS/httpProxy.conf`; - j="${j#javastart_priority=}" - if [ ! -z "$j" ];then - if [ -n $j ]; then JAVA="nice -n $j $JAVA"; fi; - fi - -# for i in `grep javastart DATA/SETTINGS/httpProxy.conf`;do -# i="${i#javastart_*=}"; -# JAVA_ARGS="-$i $JAVA_ARGS"; -# done -fi -#echo "JAVA_ARGS: $JAVA_ARGS" -#echo "JAVA: $JAVA" - -# generating the proper classpath -CLASSPATH="lib/YaCyUpdater_r3.jar:" -for N in lib/*.jar; do CLASSPATH="$CLASSPATH$N:"; done -for N in libx/*.jar; do CLASSPATH="$CLASSPATH$N:"; done -CLASSPATH="classes:.:htroot:$CLASSPATH" - - -cmdline=""; -if [ $DEBUG -eq 1 ] #debug -then - cmdline="$JAVA $JAVA_ARGS -Djava.awt.headless=true -classpath $CLASSPATH yacy" -elif [ $LOGGING -eq 1 ];then #logging - cmdline="$JAVA $JAVA_ARGS -Djava.awt.headless=true -classpath $CLASSPATH yacy >> yacy.log &" -else - cmdline="$JAVA $JAVA_ARGS -Djava.awt.headless=true -classpath $CLASSPATH yacy &> /dev/null &" -fi -if [ $PRINTONLY -eq 1 ];then - echo $cmdline -else - 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.sh 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:8080 << " - eval $cmdline - if [ "$TAILLOG" -eq "1" -a ! "$DEBUG" -eq "1" ];then - tail -f DATA/LOG/yacy00.log - fi -fi