Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
Windows installer now detects reliably whether YaCy runs. A file lock on the yacy.running file has been implemented.
Lotus411aab02e3ab
diff --git a/build.nsi b/build.nsiindex 436bd95dd..3fcd99e79 100755--- a/build.nsi+++ b/build.nsi@@ -207,7 +207,9 @@ SectionEnd; UNINSTALLERSection "Uninstall"- IfFileExists "$INSTDIR\DATA\yacy.running" 0 uninstall+ ClearErrors+ Delete "$INSTDIR\DATA\yacy.running"+ IfErrors 0 uninstallMessageBox MB_ICONSTOP "$(stillRunning)" /SD IDOKGoto nouninstalldiff --git a/source/net/yacy/yacy.java b/source/net/yacy/yacy.javaindex b6af8112e..77d6a4861 100644--- a/source/net/yacy/yacy.java+++ b/source/net/yacy/yacy.java@@ -36,6 +36,9 @@ import java.io.FileWriter;import java.io.IOException;import java.io.InputStreamReader;import java.io.PrintWriter;+import java.io.RandomAccessFile;+import java.nio.channels.FileChannel;+import java.nio.channels.FileLock;import java.util.Iterator;import java.util.Map;import java.util.Properties;@@ -200,6 +203,12 @@ public final class yacy {Log.logSevere("STARTUP", "WARNING: the file " + f + " can not be created!");try { new FileOutputStream(f).write(Integer.toString(OS.getPID()).getBytes()); } catch (final Exception e) { } // write PIDf.deleteOnExit();+ FileChannel channel = null;+ FileLock lock = null;+ try {+ channel = new RandomAccessFile(f,"rw").getChannel();+ lock = channel.tryLock(); // lock yacy.running+ } catch (final Exception e) { };final String oldconf = "DATA/SETTINGS/httpProxy.conf".replace("/", File.separator);final String newconf = "DATA/SETTINGS/yacy.conf".replace("/", File.separator);@@ -403,6 +412,8 @@ public final class yacy {Log.logSevere("STARTUP", "Unexpected Error: " + e.getClass().getName(),e);//System.exit(1);}+ if(lock != null) lock.release();+ if(channel != null) channel.close();} catch (final Exception ee) {Log.logSevere("STARTUP", "FATAL ERROR: " + ee.getMessage(),ee);} finally {