diff options
| author | Daniil Fedotov <dfedotov@pivotal.io> | 2016-02-22 11:15:40 +0000 |
|---|---|---|
| committer | Daniil Fedotov <dfedotov@pivotal.io> | 2016-02-22 11:15:40 +0000 |
| commit | d937467ee05b0eef81f3ba2b4d420cbc3df98f50 (patch) | |
| tree | 2e70c23c4f2f16943971942233289dad52d7c87f /src | |
| parent | 173260d91e1f10ba0e5ef2cd16889ccd5bb28dab (diff) | |
| download | rabbitmq-server-git-d937467ee05b0eef81f3ba2b4d420cbc3df98f50.tar.gz | |
Config location logging
Diffstat (limited to 'src')
| -rw-r--r-- | src/rabbit.erl | 27 | ||||
| -rw-r--r-- | src/rabbit_config.erl | 49 |
2 files changed, 46 insertions, 30 deletions
diff --git a/src/rabbit.erl b/src/rabbit.erl index 278ec0197d..9541f7c0b6 100644 --- a/src/rabbit.erl +++ b/src/rabbit.erl @@ -803,32 +803,7 @@ home_dir() -> end. config_files() -> - Abs = fun (F) -> - filename:absname(filename:rootname(F, ".config") ++ ".config") - end, - case init:get_argument(config) of - {ok, Files} -> [Abs(File) || [File] <- Files]; - error -> case config_setting() of - none -> []; - File -> [Abs(File) ++ " (not found)"] - end - end. - -%% This is a pain. We want to know where the config file is. But we -%% can't specify it on the command line if it is missing or the VM -%% will fail to start, so we need to find it by some mechanism other -%% than init:get_arguments/0. We can look at the environment variable -%% which is responsible for setting it... but that doesn't work for a -%% Windows service since the variable can change and the service not -%% be reinstalled, so in that case we add a magic application env. -config_setting() -> - case application:get_env(rabbit, windows_service_config) of - {ok, File1} -> File1; - undefined -> case os:getenv("RABBITMQ_CONFIG_FILE") of - false -> none; - File2 -> File2 - end - end. + rabbit_config:config_files(). %% We don't want this in fhc since it references rabbit stuff. And we can't put %% this in the bootstep directly. diff --git a/src/rabbit_config.erl b/src/rabbit_config.erl index 4bccc5d0c7..e467a73d7c 100644 --- a/src/rabbit_config.erl +++ b/src/rabbit_config.erl @@ -5,7 +5,9 @@ prepare_and_use_config/0, prepare_config/1, update_app_config/1, - schema_dir/0]). + schema_dir/0, + config_files/0 + ]). prepare_and_use_config() -> case erlang_config_used() of @@ -28,7 +30,7 @@ prepare_and_use_config() -> erlang_config_used() -> case init:get_argument(config) of error -> false; - {ok, Config} -> + {ok, [Config | _]} -> ConfigFile = Config ++ ".config", rabbit_file:is_file(ConfigFile) andalso @@ -80,7 +82,6 @@ generate_config_file(ConfFiles, ConfDir, ScriptDir) -> " -e ", "\"", ConfDir, "\"", [[" -c ", ConfFile] || ConfFile <- ConfFiles], AdvancedConfigArg]), - io:format("Command: ~s~n", [Command]), Result = rabbit_misc:os_cmd(Command), case string:str(Result, " -config ") of 0 -> {error, {generation_error, Result}}; @@ -104,7 +105,8 @@ schema_dir() -> get_advanced_config() -> case init:get_argument(conf_advanced) of - {ok, FileName} -> + % There can be only one advanced.config + {ok, [FileName | _]} -> ConfigName = FileName ++ ".config", case rabbit_file:is_file(ConfigName) of true -> {ok, ConfigName}; @@ -121,4 +123,43 @@ prepare_plugin_schemas(SchemaDir) -> end. +config_files() -> + Abs = fun (F, Ex) -> filename:absname(filename:rootname(F, Ex) ++ Ex) end, + case erlang_config_used() of + true -> + case init:get_argument(config) of + {ok, Files} -> [Abs(File, ".config") || [File] <- Files]; + error -> case config_setting() of + none -> []; + File -> [Abs(File, ".config") + ++ + " (not found)"] + end + end; + false -> + ConfFiles = [Abs(File, ".conf") || File <- get_confs()], + AdvancedFiles = case get_advanced_config() of + none -> []; + {ok, FileName} -> [Abs(FileName, ".config")] + end, + AdvancedFiles ++ ConfFiles + + end. + + +%% This is a pain. We want to know where the config file is. But we +%% can't specify it on the command line if it is missing or the VM +%% will fail to start, so we need to find it by some mechanism other +%% than init:get_arguments/0. We can look at the environment variable +%% which is responsible for setting it... but that doesn't work for a +%% Windows service since the variable can change and the service not +%% be reinstalled, so in that case we add a magic application env. +config_setting() -> + case application:get_env(rabbit, windows_service_config) of + {ok, File1} -> File1; + undefined -> case os:getenv("RABBITMQ_CONFIG_FILE") of + false -> none; + File2 -> File2 + end + end. |
