This commit is contained in:
Michael Peter Christen 2021-01-25 11:49:32 +01:00
commit 13a2e6dc6e
7 changed files with 760 additions and 753 deletions

View File

@ -135,10 +135,10 @@ network.unit.definition = defaults/yacy.network.freeworld.unit
# This option is only valid if the network.unit.domain property is set to 'any' # This option is only valid if the network.unit.domain property is set to 'any'
network.unit.domain.nocheck = false network.unit.domain.nocheck = false
# in addition to non-dht networks a client may have its own agent name # A client may have its own agent name. This name can be set by the user and is set to a random value
# this option is only used if the value is non-empty and network.unit.dht = false # if not overwritten by the user. As an alternative, the name can be set with this property.
# that means it is not usable in YaCy p2p-configurations, only in private portal configurations # This option is only used if the value is non-empty.
network.unit.tenant.agent = network.unit.agent =
# Prefer https for in-protocol operations when available on remote peers # Prefer https for in-protocol operations when available on remote peers
# A distinct general setting is available to control whether https sould be used for remote search queries : remotesearch.https.preferred # A distinct general setting is available to control whether https sould be used for remote search queries : remotesearch.https.preferred

View File

@ -224,7 +224,7 @@ public class ConfigNetwork_p
prop.putHTML("network.unit.name", sb.getConfig(SwitchboardConstants.NETWORK_NAME, "")); prop.putHTML("network.unit.name", sb.getConfig(SwitchboardConstants.NETWORK_NAME, ""));
prop.putHTML("network.unit.description", sb.getConfig("network.unit.description", "")); prop.putHTML("network.unit.description", sb.getConfig("network.unit.description", ""));
prop.putHTML("network.unit.domain", sb.getConfig(SwitchboardConstants.NETWORK_DOMAIN, "")); prop.putHTML("network.unit.domain", sb.getConfig(SwitchboardConstants.NETWORK_DOMAIN, ""));
prop.putHTML("network.unit.dht", sb.getConfig(SwitchboardConstants.DHT_ENABLED, "")); prop.putHTML("network.unit.dht", sb.getConfig(SwitchboardConstants.NETWORK_UNIT_DHT, ""));
networkBootstrapLocations.remove(sb.getConfig("network.unit.definition", "")); networkBootstrapLocations.remove(sb.getConfig("network.unit.definition", ""));
int c = 0; int c = 0;
for ( final String s : networkBootstrapLocations ) { for ( final String s : networkBootstrapLocations ) {

View File

@ -1039,7 +1039,7 @@ public class YaCyDefaultServlet extends HttpServlet {
templatePatterns.put("simpleheadernavbar", sb.getConfig("decoration.simpleheadernavbar", "navbar-default")); templatePatterns.put("simpleheadernavbar", sb.getConfig("decoration.simpleheadernavbar", "navbar-default"));
// add navigation keys to enable or disable menu items // add navigation keys to enable or disable menu items
templatePatterns.put("navigation-p2p", sb.getConfigBool(SwitchboardConstants.DHT_ENABLED, true) || !sb.isRobinsonMode() ? 1 : 0); templatePatterns.put("navigation-p2p", sb.getConfigBool(SwitchboardConstants.NETWORK_UNIT_DHT, true) || !sb.isRobinsonMode() ? 1 : 0);
templatePatterns.put("navigation-p2p_authorized", authorized ? 1 : 0); templatePatterns.put("navigation-p2p_authorized", authorized ? 1 : 0);
String submitted = sb.getConfig("server.servlets.submitted", ""); String submitted = sb.getConfig("server.servlets.submitted", "");
boolean crawler_enabled = true; /* boolean crawler_enabled = true; /*

View File

@ -633,6 +633,8 @@ public final class Switchboard extends serverSwitch {
partitionExponent, partitionExponent,
false, false,
this.exceed134217727); this.exceed134217727);
String agent = getConfig(SwitchboardConstants.NETWORK_UNIT_AGENT, "");
if (!agent.isEmpty()) this.peers.setMyName(agent); // this can thus be set using the environment variable yacy.network.unit.agent
this.localpeers = Collections.newSetFromMap(new ConcurrentHashMap<>()); this.localpeers = Collections.newSetFromMap(new ConcurrentHashMap<>());
new OneTimeBusyThread("Switchboard.scanForOtherYaCyInIntranet") { new OneTimeBusyThread("Switchboard.scanForOtherYaCyInIntranet") {
@Override @Override
@ -3473,7 +3475,7 @@ public final class Switchboard extends serverSwitch {
condenser, condenser,
searchEvent, searchEvent,
sourceName, sourceName,
getConfigBool(SwitchboardConstants.DHT_ENABLED, false), getConfigBool(SwitchboardConstants.NETWORK_UNIT_DHT, false),
this.getConfigBool(SwitchboardConstants.PROXY_TRANSPARENT_PROXY, false) ? "http://127.0.0.1:" + sb.getConfigInt(SwitchboardConstants.SERVER_PORT, 8090) : null, this.getConfigBool(SwitchboardConstants.PROXY_TRANSPARENT_PROXY, false) ? "http://127.0.0.1:" + sb.getConfigInt(SwitchboardConstants.SERVER_PORT, 8090) : null,
this.getConfig("crawler.http.acceptLanguage", null)); this.getConfig("crawler.http.acceptLanguage", null));
final RSSFeed feed = final RSSFeed feed =
@ -4142,7 +4144,7 @@ public final class Switchboard extends serverSwitch {
if ( this.peers.noDHTActivity() ) { if ( this.peers.noDHTActivity() ) {
return "no DHT distribution: network too small"; return "no DHT distribution: network too small";
} }
if ( !getConfigBool(SwitchboardConstants.DHT_ENABLED, true) ) { if ( !getConfigBool(SwitchboardConstants.NETWORK_UNIT_DHT, true) ) {
return "no DHT distribution: disabled by network.unit.dht"; return "no DHT distribution: disabled by network.unit.dht";
} }
if ( getConfig(SwitchboardConstants.INDEX_DIST_ALLOW, "false").equalsIgnoreCase("false") ) { if ( getConfig(SwitchboardConstants.INDEX_DIST_ALLOW, "false").equalsIgnoreCase("false") ) {

View File

@ -267,9 +267,9 @@ public final class SwitchboardConstants {
/** Default value for the global HTTP Referrer policy delivered by meta tag */ /** Default value for the global HTTP Referrer policy delivered by meta tag */
public static final String REFERRER_META_POLICY_DEFAULT = "origin-when-cross-origin"; public static final String REFERRER_META_POLICY_DEFAULT = "origin-when-cross-origin";
public static final String DHT_ENABLED = "network.unit.dht";
public static final String NETWORK_UNIT_DHT = "network.unit.dht";
public static final String NETWORK_UNIT_AGENT = "network.unit.agent";
public static final String REMOTESEARCH_MAXCOUNT_DEFAULT = "network.unit.remotesearch.maxcount"; public static final String REMOTESEARCH_MAXCOUNT_DEFAULT = "network.unit.remotesearch.maxcount";
public static final String REMOTESEARCH_MAXTIME_DEFAULT = "network.unit.remotesearch.maxtime"; public static final String REMOTESEARCH_MAXTIME_DEFAULT = "network.unit.remotesearch.maxtime";
public static final String REMOTESEARCH_MAXCOUNT_USER = "remotesearch.maxcount"; public static final String REMOTESEARCH_MAXCOUNT_USER = "remotesearch.maxcount";

File diff suppressed because it is too large Load Diff

View File

@ -157,13 +157,13 @@ public final class yacy {
mkdirsIfNeseccary(appHome); mkdirsIfNeseccary(appHome);
File f = new File(dataHome, "DATA/"); File f = new File(dataHome, "DATA/");
mkdirsIfNeseccary(f); mkdirsIfNeseccary(f);
if (!(f.exists())) { if (!(f.exists())) {
System.err.println("Error creating DATA-directory in " + dataHome.toString() + " . Please check your write-permission for this folder. YaCy will now terminate."); System.err.println("Error creating DATA-directory in " + dataHome.toString() + " . Please check your write-permission for this folder. YaCy will now terminate.");
System.exit(-1); System.exit(-1);
} }
// set jvm tmpdir to a subdir for easy cleanup (as extensive use file.deleteonexit waists memory during long runs, as todelete files names are collected and never cleaned up during runtime) // set jvm tmpdir to a subdir for easy cleanup (as extensive use file.deleteonexit waists memory during long runs, as todelete files names are collected and never cleaned up during runtime)
// keep this as earlier as possible, as any other class can use the "java.io.tmpdir" property, even the log manager, when the log file pattern uses "%t" as an alias for the tmp directory // keep this as earlier as possible, as any other class can use the "java.io.tmpdir" property, even the log manager, when the log file pattern uses "%t" as an alias for the tmp directory
try { try {
tmpdir = java.nio.file.Files.createTempDirectory("yacy-tmp-").toString(); // creates sub dir in jvm's temp (see System.property "java.io.tempdir") tmpdir = java.nio.file.Files.createTempDirectory("yacy-tmp-").toString(); // creates sub dir in jvm's temp (see System.property "java.io.tempdir")
System.setProperty("java.io.tmpdir", tmpdir); System.setProperty("java.io.tmpdir", tmpdir);
@ -173,9 +173,9 @@ public final class yacy {
f = new File(dataHome, "DATA/LOG/"); f = new File(dataHome, "DATA/LOG/");
mkdirsIfNeseccary(f); mkdirsIfNeseccary(f);
f = new File(f, "yacy.logging"); f = new File(f, "yacy.logging");
final File f0 = new File(appHome, "defaults/yacy.logging"); final File f0 = new File(appHome, "defaults/yacy.logging");
if (!f.exists() || f0.lastModified() > f.lastModified()) try { if (!f.exists() || f0.lastModified() > f.lastModified()) try {
Files.copy(f0, f); Files.copy(f0, f);
} catch (final IOException e){ } catch (final IOException e){
System.out.println("could not copy yacy.logging: " + e.getMessage()); System.out.println("could not copy yacy.logging: " + e.getMessage());
} }
@ -194,17 +194,17 @@ public final class yacy {
ConcurrentLog.config("STARTUP", "Maximum file system path length: " + OS.maxPathLength); ConcurrentLog.config("STARTUP", "Maximum file system path length: " + OS.maxPathLength);
f = new File(dataHome, "DATA/yacy.running"); f = new File(dataHome, "DATA/yacy.running");
final String conf = "DATA/SETTINGS/yacy.conf".replace("/", File.separator);
if (!f.createNewFile()) ConcurrentLog.severe("STARTUP", "WARNING: the file " + f + " can not be created!"); if (!f.createNewFile()) ConcurrentLog.severe("STARTUP", "WARNING: the file " + f + " can not be created!");
try { new FileOutputStream(f).write(Integer.toString(OS.getPID()).getBytes()); } catch (final Exception e) { } // write PID try { new FileOutputStream(f).write(Integer.toString(OS.getPID()).getBytes()); } catch (final Exception e) { } // write PID
f.deleteOnExit(); f.deleteOnExit();
FileChannel channel = null; FileChannel channel = null;
FileLock lock = null; FileLock lock = null;
try { try {
channel = new RandomAccessFile(f,"rw").getChannel(); channel = new RandomAccessFile(f,"rw").getChannel();
lock = channel.tryLock(); // lock yacy.running lock = channel.tryLock(); // lock yacy.running
} catch (final Exception e) { } } catch (final Exception e) { }
final String conf = "DATA/SETTINGS/yacy.conf".replace("/", File.separator);
try { try {
sb = new Switchboard(dataHome, appHome, "defaults/yacy.init".replace("/", File.separator), conf); sb = new Switchboard(dataHome, appHome, "defaults/yacy.init".replace("/", File.separator), conf);
} catch (final RuntimeException e) { } catch (final RuntimeException e) {
@ -227,7 +227,7 @@ public final class yacy {
sb.setConfig("htTemplatePath", "htroot/env/templates"); sb.setConfig("htTemplatePath", "htroot/env/templates");
double oldVer; double oldVer;
try { try {
String tmpversion = sb.getConfig(Seed.VERSION, ""); String tmpversion = sb.getConfig(Seed.VERSION, "");
if (tmpversion.isEmpty()) { // before 1.83009737 only the svnRevision nr was in config (like 9737) if (tmpversion.isEmpty()) { // before 1.83009737 only the svnRevision nr was in config (like 9737)
tmpversion = yacyBuildProperties.getVersion(); tmpversion = yacyBuildProperties.getVersion();
@ -242,7 +242,7 @@ public final class yacy {
} }
} catch (final NumberFormatException e) { } catch (final NumberFormatException e) {
oldVer = 0.0d; oldVer = 0.0d;
} }
final double newRev = Double.parseDouble(yacyBuildProperties.getLongVersion()); final double newRev = Double.parseDouble(yacyBuildProperties.getLongVersion());
sb.setConfig(Seed.VERSION, yacyBuildProperties.getLongVersion()); sb.setConfig(Seed.VERSION, yacyBuildProperties.getLongVersion());
sb.setConfig("applicationRoot", appHome.toString()); sb.setConfig("applicationRoot", appHome.toString());
@ -294,7 +294,7 @@ public final class yacy {
final int port = sb.getLocalPort(); final int port = sb.getLocalPort();
try { try {
// start http server // start http server
YaCyHttpServer httpServer; YaCyHttpServer httpServer;
httpServer = new Jetty9HttpServerImpl(port); httpServer = new Jetty9HttpServerImpl(port);
httpServer.startupServer(); httpServer.startupServer();
sb.setHttpServer(httpServer); sb.setHttpServer(httpServer);
@ -312,10 +312,10 @@ public final class yacy {
/* YaCy main startup process must not hang because browser opening is long or fails. /* YaCy main startup process must not hang because browser opening is long or fails.
* Let's open try opening the browser in a separate thread */ * Let's open try opening the browser in a separate thread */
new Thread("Browser opening") { new Thread("Browser opening") {
@Override @Override
public void run() { public void run() {
Browser.openBrowser(("http://localhost:"+port) + "/" + browserPopUpPage); Browser.openBrowser(("http://localhost:"+port) + "/" + browserPopUpPage);
} }
}.start(); }.start();
// Browser.openBrowser((server.withSSL()?"https":"http") + "://localhost:" + serverCore.getPortNr(port) + "/" + browserPopUpPage); // Browser.openBrowser((server.withSSL()?"https":"http") + "://localhost:" + serverCore.getPortNr(port) + "/" + browserPopUpPage);
} catch (final Throwable e) { } catch (final Throwable e) {
@ -347,11 +347,11 @@ public final class yacy {
} catch (final IOException e) { } catch (final IOException e) {
//Error //Error
} finally { } finally {
try { try {
br.close(); br.close();
} catch(IOException ioe) { } catch(IOException ioe) {
ConcurrentLog.warn("STARTUP", "Could not close " + tmplang + " version file"); ConcurrentLog.warn("STARTUP", "Could not close " + tmplang + " version file");
} }
} }
if (currentRev == null || !currentRev.equals(sb.getConfig(Seed.VERSION, ""))) { if (currentRev == null || !currentRev.equals(sb.getConfig(Seed.VERSION, ""))) {
@ -420,35 +420,35 @@ public final class yacy {
} catch (final Exception e) {} // was once stopped by de.anomic.net.ftpc$sm.checkExit(ftpc.java:1790) } catch (final Exception e) {} // was once stopped by de.anomic.net.ftpc$sm.checkExit(ftpc.java:1790)
} }
/** /**
* @param f * @param f
*/ */
private static void delete(final File f) { private static void delete(final File f) {
if(!f.delete()) if(!f.delete())
ConcurrentLog.severe("STARTUP", "WARNING: the file " + f + " can not be deleted!"); ConcurrentLog.severe("STARTUP", "WARNING: the file " + f + " can not be deleted!");
} }
/** /**
* @see File#mkdir() * @see File#mkdir()
* @param path * @param path
*/ */
private static void mkdirIfNeseccary(final File path) { private static void mkdirIfNeseccary(final File path) {
if (!(path.exists())) if (!(path.exists()))
if(!path.mkdir()) if(!path.mkdir())
ConcurrentLog.warn("STARTUP", "could not create directory "+ path.toString()); ConcurrentLog.warn("STARTUP", "could not create directory "+ path.toString());
} }
/** /**
* @see File#mkdirs() * @see File#mkdirs()
* @param path * @param path
*/ */
public static void mkdirsIfNeseccary(final File path) { public static void mkdirsIfNeseccary(final File path) {
if (!(path.exists())) if (!(path.exists()))
if(!path.mkdirs()) if(!path.mkdirs())
ConcurrentLog.warn("STARTUP", "could not create directories "+ path.toString()); ConcurrentLog.warn("STARTUP", "could not create directories "+ path.toString());
} }
/** /**
* Loads the configuration from the data-folder. * Loads the configuration from the data-folder.
* FIXME: Why is this called over and over again from every method, instead * FIXME: Why is this called over and over again from every method, instead
* of setting the configurationdata once for this class in main? * of setting the configurationdata once for this class in main?
@ -470,8 +470,8 @@ public final class yacy {
final Properties config = new Properties(); final Properties config = new Properties();
FileInputStream fis = null; FileInputStream fis = null;
try { try {
fis = new FileInputStream(new File(homePath, "DATA/SETTINGS/yacy.conf")); fis = new FileInputStream(new File(homePath, "DATA/SETTINGS/yacy.conf"));
config.load(fis); config.load(fis);
} catch (final FileNotFoundException e) { } catch (final FileNotFoundException e) {
ConcurrentLog.severe(mes, "could not find configuration file."); ConcurrentLog.severe(mes, "could not find configuration file.");
@ -480,13 +480,13 @@ public final class yacy {
ConcurrentLog.severe(mes, "could not read configuration file."); ConcurrentLog.severe(mes, "could not read configuration file.");
System.exit(-1); System.exit(-1);
} finally { } finally {
if(fis != null) { if(fis != null) {
try { try {
fis.close(); fis.close();
} catch (final IOException e) { } catch (final IOException e) {
ConcurrentLog.logException(e); ConcurrentLog.logException(e);
} }
} }
} }
return config; return config;
@ -536,7 +536,7 @@ public final class yacy {
final HTTPClient con = new HTTPClient(ClientIdentification.yacyInternetCrawlerAgent); final HTTPClient con = new HTTPClient(ClientIdentification.yacyInternetCrawlerAgent);
// con.setHeader(requestHeader.entrySet()); // con.setHeader(requestHeader.entrySet());
try { try {
/* First get a valid transaction token using HTTP GET */ /* First get a valid transaction token using HTTP GET */
con.GETbytes("http://localhost:"+ port +"/" + path, adminUser, encodedPassword, false); con.GETbytes("http://localhost:"+ port +"/" + path, adminUser, encodedPassword, false);
if (con.getStatusCode() != HttpStatus.SC_OK) { if (con.getStatusCode() != HttpStatus.SC_OK) {
@ -545,7 +545,7 @@ public final class yacy {
final Header transactionTokenHeader = con.getHttpResponse().getFirstHeader(HeaderFramework.X_YACY_TRANSACTION_TOKEN); final Header transactionTokenHeader = con.getHttpResponse().getFirstHeader(HeaderFramework.X_YACY_TRANSACTION_TOKEN);
if(transactionTokenHeader == null) { if(transactionTokenHeader == null) {
throw new IOException("Could not retrieve a valid transaction token"); throw new IOException("Could not retrieve a valid transaction token");
} }
/* Then POST the request */ /* Then POST the request */
@ -554,36 +554,36 @@ public final class yacy {
if (con.getStatusCode() >= HttpStatus.SC_OK && con.getStatusCode() < HttpStatus.SC_MULTIPLE_CHOICES) { if (con.getStatusCode() >= HttpStatus.SC_OK && con.getStatusCode() < HttpStatus.SC_MULTIPLE_CHOICES) {
ConcurrentLog.config("COMMAND-STEERING", "YACY accepted steering command: " + processdescription); ConcurrentLog.config("COMMAND-STEERING", "YACY accepted steering command: " + processdescription);
} else { } else {
ConcurrentLog.severe("COMMAND-STEERING", "error response from YACY socket: " + con.getHttpResponse().getStatusLine()); ConcurrentLog.severe("COMMAND-STEERING", "error response from YACY socket: " + con.getHttpResponse().getStatusLine());
try { try {
HTTPClient.closeConnectionManager(); HTTPClient.closeConnectionManager();
} catch (final InterruptedException e1) { } catch (final InterruptedException e1) {
e1.printStackTrace(); e1.printStackTrace();
} }
RemoteInstance.closeConnectionManager(); RemoteInstance.closeConnectionManager();
System.exit(-1); System.exit(-1);
} }
} catch (final IOException e) { } catch (final IOException e) {
ConcurrentLog.severe("COMMAND-STEERING", "could not establish connection to YACY socket: " + e.getMessage()); ConcurrentLog.severe("COMMAND-STEERING", "could not establish connection to YACY socket: " + e.getMessage());
try { try {
HTTPClient.closeConnectionManager(); HTTPClient.closeConnectionManager();
} catch (final InterruptedException e1) { } catch (final InterruptedException e1) {
e1.printStackTrace(); e1.printStackTrace();
} }
RemoteInstance.closeConnectionManager(); RemoteInstance.closeConnectionManager();
System.exit(-1); System.exit(-1);
} }
try { try {
HTTPClient.closeConnectionManager(); HTTPClient.closeConnectionManager();
} catch (final InterruptedException e) { } catch (final InterruptedException e) {
e.printStackTrace(); e.printStackTrace();
} }
RemoteInstance.closeConnectionManager(); RemoteInstance.closeConnectionManager();
// finished // finished
@ -609,7 +609,7 @@ public final class yacy {
ConcurrentLog.config("COMMAND-STEERING", "YACY accepted steering command: " + processdescription); ConcurrentLog.config("COMMAND-STEERING", "YACY accepted steering command: " + processdescription);
} else { } else {
ConcurrentLog.severe("COMMAND-STEERING", "error response from YACY socket: " + con.getHttpResponse().getStatusLine()); ConcurrentLog.severe("COMMAND-STEERING", "error response from YACY socket: " + con.getHttpResponse().getStatusLine());
System.exit(-1); System.exit(-1);
} }
} catch (final IOException e) { } catch (final IOException e) {
@ -618,10 +618,10 @@ public final class yacy {
} }
try { try {
HTTPClient.closeConnectionManager(); HTTPClient.closeConnectionManager();
} catch (final InterruptedException e) { } catch (final InterruptedException e) {
e.printStackTrace(); e.printStackTrace();
} }
RemoteInstance.closeConnectionManager(); RemoteInstance.closeConnectionManager();
// finished // finished
@ -678,11 +678,11 @@ public final class yacy {
ConcurrentLog.logException(ex); ConcurrentLog.logException(ex);
ConcurrentLog.severe("Startup", "cannot read " + configFile.toString() + ", please delete the corrupted file if problem persits"); ConcurrentLog.severe("Startup", "cannot read " + configFile.toString() + ", please delete the corrupted file if problem persits");
} finally { } finally {
try { try {
fis.close(); fis.close();
} catch (IOException e) { } catch (IOException e) {
ConcurrentLog.warn("Startup", "Could not close file " + configFile); ConcurrentLog.warn("Startup", "Could not close file " + configFile);
} }
} }
} }
} }
@ -696,68 +696,68 @@ public final class yacy {
*/ */
public static void main(String args[]) { public static void main(String args[]) {
try { try {
// check assertion status // check assertion status
//ClassLoader.getSystemClassLoader().setDefaultAssertionStatus(true); //ClassLoader.getSystemClassLoader().setDefaultAssertionStatus(true);
boolean assertionenabled = false; boolean assertionenabled = false;
assert (assertionenabled = true) == true; // compare to true to remove warning: "Possible accidental assignement" assert (assertionenabled = true) == true; // compare to true to remove warning: "Possible accidental assignement"
if (assertionenabled) System.out.println("Asserts are enabled"); if (assertionenabled) System.out.println("Asserts are enabled");
// check memory amount // check memory amount
System.gc(); System.gc();
final long startupMemFree = MemoryControl.free(); final long startupMemFree = MemoryControl.free();
final long startupMemTotal = MemoryControl.total(); final long startupMemTotal = MemoryControl.total();
// maybe go into headless awt mode: we have three cases depending on OS and one exception: // maybe go into headless awt mode: we have three cases depending on OS and one exception:
// windows : better do not go into headless mode // windows : better do not go into headless mode
// mac : go into headless mode because an application is shown in gui which may not be wanted // mac : go into headless mode because an application is shown in gui which may not be wanted
// linux : go into headless mode because this does not need any head operation // linux : go into headless mode because this does not need any head operation
// exception : if the -gui option is used then do not go into headless mode since that uses a gui // exception : if the -gui option is used then do not go into headless mode since that uses a gui
boolean headless = true; boolean headless = true;
if (OS.isWindows) headless = false; if (OS.isWindows) headless = false;
if (args.length >= 1 && args[0].toLowerCase(Locale.ROOT).equals("-gui")) headless = false; if (args.length >= 1 && args[0].toLowerCase(Locale.ROOT).equals("-gui")) headless = false;
System.setProperty("java.awt.headless", headless ? "true" : "false"); System.setProperty("java.awt.headless", headless ? "true" : "false");
String s = ""; for (final String a: args) s += a + " "; String s = ""; for (final String a: args) s += a + " ";
yacyRelease.startParameter = s.trim(); yacyRelease.startParameter = s.trim();
File applicationRoot = new File(System.getProperty("user.dir").replace('\\', '/')); File applicationRoot = new File(System.getProperty("user.dir").replace('\\', '/'));
File dataRoot = applicationRoot; File dataRoot = applicationRoot;
//System.out.println("args.length=" + args.length); //System.out.println("args.length=" + args.length);
//System.out.print("args=["); for (int i = 0; i < args.length; i++) System.out.print(args[i] + ", "); System.out.println("]"); //System.out.print("args=["); for (int i = 0; i < args.length; i++) System.out.print(args[i] + ", "); System.out.println("]");
if ((args.length >= 1) && (args[0].toLowerCase(Locale.ROOT).equals("-startup") || args[0].equals("-start"))) { if ((args.length >= 1) && (args[0].toLowerCase(Locale.ROOT).equals("-startup") || args[0].equals("-start"))) {
// normal start-up of yacy // normal start-up of yacy
if (args.length > 1) { if (args.length > 1) {
dataRoot = new File(args[1]); dataRoot = new File(args[1]);
if(!dataRoot.isAbsolute()) { if(!dataRoot.isAbsolute()) {
/* data root folder provided as a path relative to the user home folder */ /* data root folder provided as a path relative to the user home folder */
dataRoot = new File(System.getProperty("user.home").replace('\\', '/'), args[1]); dataRoot = new File(System.getProperty("user.home").replace('\\', '/'), args[1]);
} }
} }
preReadSavedConfigandInit(dataRoot); preReadSavedConfigandInit(dataRoot);
startup(dataRoot, applicationRoot, startupMemFree, startupMemTotal, false); startup(dataRoot, applicationRoot, startupMemFree, startupMemTotal, false);
} else if (args.length >= 1 && args[0].toLowerCase(Locale.ROOT).equals("-gui")) { } else if (args.length >= 1 && args[0].toLowerCase(Locale.ROOT).equals("-gui")) {
// start-up of yacy with gui // start-up of yacy with gui
if (args.length > 1) { if (args.length > 1) {
dataRoot = new File(args[1]); dataRoot = new File(args[1]);
if(!dataRoot.isAbsolute()) { if(!dataRoot.isAbsolute()) {
/* data root folder provided as a path relative to the user home folder */ /* data root folder provided as a path relative to the user home folder */
dataRoot = new File(System.getProperty("user.home").replace('\\', '/'), args[1]); dataRoot = new File(System.getProperty("user.home").replace('\\', '/'), args[1]);
} }
} }
preReadSavedConfigandInit(dataRoot); preReadSavedConfigandInit(dataRoot);
startup(dataRoot, applicationRoot, startupMemFree, startupMemTotal, true); startup(dataRoot, applicationRoot, startupMemFree, startupMemTotal, true);
} else if ((args.length >= 1) && ((args[0].toLowerCase(Locale.ROOT).equals("-shutdown")) || (args[0].equals("-stop")))) { } else if ((args.length >= 1) && ((args[0].toLowerCase(Locale.ROOT).equals("-shutdown")) || (args[0].equals("-stop")))) {
// normal shutdown of yacy // normal shutdown of yacy
if (args.length == 2) applicationRoot= new File(args[1]); if (args.length == 2) applicationRoot= new File(args[1]);
shutdown(applicationRoot); shutdown(applicationRoot);
} else if ((args.length >= 1) && (args[0].toLowerCase(Locale.ROOT).equals("-update"))) { } else if ((args.length >= 1) && (args[0].toLowerCase(Locale.ROOT).equals("-update"))) {
// aut-update yacy // aut-update yacy
if (args.length == 2) applicationRoot= new File(args[1]); if (args.length == 2) applicationRoot= new File(args[1]);
update(applicationRoot); update(applicationRoot);
} else if ((args.length >= 1) && (args[0].toLowerCase(Locale.ROOT).equals("-version"))) { } else if ((args.length >= 1) && (args[0].toLowerCase(Locale.ROOT).equals("-version"))) {
// show yacy version // show yacy version
System.out.println(copyright); System.out.println(copyright);
} else if ((args.length > 1) && (args[0].toLowerCase(Locale.ROOT).equals("-config"))) { } else if ((args.length > 1) && (args[0].toLowerCase(Locale.ROOT).equals("-config"))) {
// set config parameter. Special handling of adminAccount=user:pwd (generates md5 encoded password) // set config parameter. Special handling of adminAccount=user:pwd (generates md5 encoded password)
// on Windows parameter should be enclosed in doublequotes to accept = sign (e.g. -config "port=8090" "port.ssl=8043") // on Windows parameter should be enclosed in doublequotes to accept = sign (e.g. -config "port=8090" "port.ssl=8043")
@ -805,15 +805,15 @@ public final class yacy {
System.out.println(); System.out.println();
} }
} else { } else {
if (args.length == 1) { if (args.length == 1) {
applicationRoot= new File(args[0]); applicationRoot= new File(args[0]);
} }
preReadSavedConfigandInit(dataRoot); preReadSavedConfigandInit(dataRoot);
startup(dataRoot, applicationRoot, startupMemFree, startupMemTotal, false); startup(dataRoot, applicationRoot, startupMemFree, startupMemTotal, false);
} }
} finally { } finally {
ConcurrentLog.shutdown(); ConcurrentLog.shutdown();
} }
} }
} }