Allow to pass es.default. settings to the process, using it as default value unless specified in the config file, closes #2016.
This commit is contained in:
parent
6d867126c9
commit
8072af9078
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue