another fix to the restart function; now tested under linux

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@3947 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 18 years ago
parent 2158f83d43
commit 21fabe259b

@ -6,7 +6,7 @@
// //
// $LastChangedDate$ // $LastChangedDate$
// $LastChangedRevision$ // $LastChangedRevision$
// $LastChangedBy$ // $LastChangedBy: $
// //
// ThreadPool // ThreadPool
// //
@ -95,7 +95,9 @@ public final class serverCore extends serverAbstractThread implements serverThre
public static final byte lf = 10; public static final byte lf = 10;
public static final byte[] crlf = {cr, lf}; public static final byte[] crlf = {cr, lf};
public static final String crlfString = new String(crlf); public static final String crlfString = new String(crlf);
public static final String lfstring = new String(new byte[]{lf});
public static final Class[] stringType = {"".getClass()}; // set up some reflection public static final Class[] stringType = {"".getClass()}; // set up some reflection
//Class[] exceptionType = {Class.forName("java.lang.Throwable")}; //Class[] exceptionType = {Class.forName("java.lang.Throwable")};

@ -50,9 +50,6 @@ import java.util.Hashtable;
import java.util.Properties; import java.util.Properties;
import java.util.Vector; import java.util.Vector;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.logging.serverLog;
public final class serverSystem { public final class serverSystem {
// constants for system identification // constants for system identification
@ -342,7 +339,8 @@ public final class serverSystem {
public static void execAsynchronous(File scriptFile) throws IOException { public static void execAsynchronous(File scriptFile) throws IOException {
// runs a unix/linux script as separate thread // runs a unix/linux script as separate thread
File starterFile = new File(scriptFile.getAbsolutePath() + ".starter.sh"); File starterFile = new File(scriptFile.getAbsolutePath() + ".starter.sh");
deployScript(starterFile, scriptFile.getAbsolutePath() + " &"); //deployScript(starterFile, "touch restart.starter.startet1");
deployScript(starterFile, scriptFile.getAbsolutePath() + " &" + serverCore.lfstring);
try { try {
Runtime.getRuntime().exec(starterFile.getAbsolutePath()).waitFor(); Runtime.getRuntime().exec(starterFile.getAbsolutePath()).waitFor();
} catch (InterruptedException e) { } catch (InterruptedException e) {

@ -27,10 +27,8 @@
package de.anomic.yacy; package de.anomic.yacy;
import java.io.BufferedReader;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.util.Comparator; import java.util.Comparator;
import java.util.Iterator; import java.util.Iterator;
@ -41,6 +39,7 @@ import de.anomic.htmlFilter.htmlFilterContentScraper;
import de.anomic.http.httpc; import de.anomic.http.httpc;
import de.anomic.net.URL; import de.anomic.net.URL;
import de.anomic.plasma.plasmaSwitchboard; import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverCore;
import de.anomic.server.serverFileUtils; import de.anomic.server.serverFileUtils;
import de.anomic.server.serverSystem; import de.anomic.server.serverSystem;
import de.anomic.server.logging.serverLog; import de.anomic.server.logging.serverLog;
@ -288,7 +287,7 @@ public final class yacyVersion implements Comparator, Comparable {
// start a re-start daemon // start a re-start daemon
try { try {
serverLog.logInfo("RESTART", "INITIATED"); serverLog.logInfo("RESTART", "INITIATED");
String script = "cd " + plasmaSwitchboard.getSwitchboard().getRootPath() + "/DATA/RELEASE/;while [ -e ../yacy.running ]; do sleep 1;done;cd ../../;./startYACY.sh"; String script = "cd " + plasmaSwitchboard.getSwitchboard().getRootPath() + "/DATA/RELEASE/" + serverCore.lfstring + "while [ -e ../yacy.running ]; do" + serverCore.lfstring + "sleep 1" + serverCore.lfstring + "done" + serverCore.lfstring + "cd ../../" + serverCore.lfstring + "nohup ./startYACY.sh > /dev/null";
File scriptFile = new File(plasmaSwitchboard.getSwitchboard().getRootPath(), "DATA/RELEASE/restart.sh"); File scriptFile = new File(plasmaSwitchboard.getSwitchboard().getRootPath(), "DATA/RELEASE/restart.sh");
serverSystem.deployScript(scriptFile, script); serverSystem.deployScript(scriptFile, script);
serverLog.logInfo("RESTART", "wrote restart-script to " + scriptFile.getAbsolutePath()); serverLog.logInfo("RESTART", "wrote restart-script to " + scriptFile.getAbsolutePath());
@ -299,28 +298,7 @@ public final class yacyVersion implements Comparator, Comparable {
serverLog.logSevere("RESTART", "restart failed", e); serverLog.logSevere("RESTART", "restart failed", e);
} }
} }
/*
if (serverSystem.canExecUnix) {
// start a re-start daemon
try {
serverLog.logInfo("RESTART", "INITIATED");
String script = "cd " + plasmaSwitchboard.getSwitchboard().getRootPath() + "/DATA/RELEASE/;while [ -e ../yacy.running ]; do sleep 1;done;cd ../../;./startYACY.sh";
File scriptFile = new File(plasmaSwitchboard.getSwitchboard().getRootPath(), "DATA/RELEASE/restart.sh");
serverFileUtils.write(script.getBytes(), scriptFile);
serverLog.logInfo("RESTART", "wrote restart-script to " + scriptFile.getAbsolutePath());
Runtime.getRuntime().exec("chmod 755 " + scriptFile.getAbsolutePath()).waitFor();
Runtime.getRuntime().exec(scriptFile.getAbsolutePath() + " &");
serverLog.logInfo("RESTART", "script is running");
plasmaSwitchboard.getSwitchboard().terminate(5000);
} catch (IOException e) {
serverLog.logSevere("RESTART", "restart failed", e);
} catch (InterruptedException e) {
serverLog.logSevere("RESTART", "restart failed", e);
} }
}
*/
}
public static void writeDeployScript(String release) { public static void writeDeployScript(String release) {
//byte[] script = ("cd " + plasmaSwitchboard.getSwitchboard().getRootPath() + ";while [ -e ../yacy.running ]; do sleep 1;done;tar xfz " + release + ";cp -Rf yacy/* ../../;rm -Rf yacy;cd ../../;startYACY.sh").getBytes(); //byte[] script = ("cd " + plasmaSwitchboard.getSwitchboard().getRootPath() + ";while [ -e ../yacy.running ]; do sleep 1;done;tar xfz " + release + ";cp -Rf yacy/* ../../;rm -Rf yacy;cd ../../;startYACY.sh").getBytes();

Loading…
Cancel
Save