From 8072af9078d1629edba547892f67a097bcd3c42c Mon Sep 17 00:00:00 2001 From: Shay Banon Date: Mon, 11 Jun 2012 13:30:55 +0200 Subject: [PATCH] Allow to pass es.default. settings to the process, using it as default value unless specified in the config file, closes #2016. --- .../node/internal/InternalSettingsPerparer.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/elasticsearch/node/internal/InternalSettingsPerparer.java b/src/main/java/org/elasticsearch/node/internal/InternalSettingsPerparer.java index ce7605bb05a..ccaefcd2050 100644 --- a/src/main/java/org/elasticsearch/node/internal/InternalSettingsPerparer.java +++ b/src/main/java/org/elasticsearch/node/internal/InternalSettingsPerparer.java @@ -39,6 +39,8 @@ public class InternalSettingsPerparer { // just create enough settings to build the environment ImmutableSettings.Builder settingsBuilder = settingsBuilder() .put(pSettings) + .putProperties("elasticsearch.default.", System.getProperties()) + .putProperties("es.default.", System.getProperties()) .putProperties("elasticsearch.", System.getProperties()) .putProperties("es.", System.getProperties()) .replacePropertyPlaceholders(); @@ -46,16 +48,22 @@ public class InternalSettingsPerparer { Environment environment = new Environment(settingsBuilder.build()); if (loadConfigSettings) { - boolean explicitSettingsProvided = false; + boolean loadFromEnv = true; + // if its default, then load it, but also load form env + if (System.getProperty("es.default.config") != null) { + loadFromEnv = true; + settingsBuilder.loadFromUrl(environment.resolveConfig(System.getProperty("es.config"))); + } + // if explicit, just load it and don't load from env if (System.getProperty("es.config") != null) { - explicitSettingsProvided = true; + loadFromEnv = false; settingsBuilder.loadFromUrl(environment.resolveConfig(System.getProperty("es.config"))); } if (System.getProperty("elasticsearch.config") != null) { - explicitSettingsProvided = true; + loadFromEnv = false; settingsBuilder.loadFromUrl(environment.resolveConfig(System.getProperty("elasticsearch.config"))); } - if (!explicitSettingsProvided) { + if (loadFromEnv) { try { settingsBuilder.loadFromUrl(environment.resolveConfig("elasticsearch.yml")); } catch (FailedToResolveConfigException e) {