mirror of
https://github.com/yacy/yacy_search_server.git
synced 2024-09-19 00:01:41 +02:00
protection against starting of a (second) yacy peer while another one is already running on the same port
git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@7917 6c8d7289-2bf4-0310-a012-ef5d649a1542
This commit is contained in:
parent
2d03dc1804
commit
3da21c4266
|
@ -66,6 +66,7 @@ import java.util.SortedSet;
|
|||
import java.util.TreeMap;
|
||||
import java.util.TreeSet;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.Semaphore;
|
||||
import java.util.regex.Pattern;
|
||||
|
@ -87,6 +88,7 @@ import net.yacy.cora.protocol.Domains;
|
|||
import net.yacy.cora.protocol.HeaderFramework;
|
||||
import net.yacy.cora.protocol.RequestHeader;
|
||||
import net.yacy.cora.protocol.ResponseHeader;
|
||||
import net.yacy.cora.protocol.TimeoutRequest;
|
||||
import net.yacy.cora.protocol.http.HTTPClient;
|
||||
import net.yacy.cora.protocol.http.ProxySettings;
|
||||
import net.yacy.cora.services.federated.solr.SolrChardingConnector;
|
||||
|
@ -255,11 +257,21 @@ public final class Switchboard extends serverSwitch {
|
|||
|
||||
public Switchboard(final File dataPath, final File appPath, final String initPath, final String configPath) throws IOException {
|
||||
super(dataPath, appPath, initPath, configPath);
|
||||
|
||||
// check if port is already occupied
|
||||
final int port = getConfigInt("port", 8090);
|
||||
try {
|
||||
if (TimeoutRequest.ping("127.0.0.1", port, 500)) {
|
||||
throw new RuntimeException("a server is already running on the YaCy port " + port + "; possibly another YaCy process has not terminated yet. Please stop YaCy before running a new instance.");
|
||||
}
|
||||
} catch (final ExecutionException e1) {
|
||||
}
|
||||
|
||||
MemoryTracker.startSystemProfiling();
|
||||
sb = this;
|
||||
|
||||
// set loglevel and log
|
||||
setLog(new Log("PLASMA"));
|
||||
setLog(new Log("YACY_SEARCH"));
|
||||
|
||||
// set default peer name
|
||||
yacySeed.ANON_PREFIX = getConfig("peernameprefix", "_anon");
|
||||
|
|
|
@ -207,7 +207,12 @@ public final class yacy {
|
|||
if(!oldconffile.renameTo(newconfFile))
|
||||
Log.logSevere("STARTUP", "WARNING: the file " + oldconffile + " can not be renamed to "+ newconfFile +"!");
|
||||
}
|
||||
sb = new Switchboard(dataHome, appHome, "defaults/yacy.init".replace("/", File.separator), newconf);
|
||||
try {
|
||||
sb = new Switchboard(dataHome, appHome, "defaults/yacy.init".replace("/", File.separator), newconf);
|
||||
} catch (final RuntimeException e) {
|
||||
Log.logSevere("STARTUP", "YaCy cannot start: " + e.getMessage());
|
||||
System.exit(-1);
|
||||
}
|
||||
//sbSync.V(); // signal that the sb reference was set
|
||||
|
||||
// switch the memory strategy
|
||||
|
|
Loading…
Reference in New Issue
Block a user