summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGerhard Lazu <gerhard@users.noreply.github.com>2020-04-23 17:18:00 +0100
committerGitHub <noreply@github.com>2020-04-23 17:18:00 +0100
commit27ed8c153c83be8086e299e5f27ce03d129f3f79 (patch)
treed944cf43c99e61c97e3035ef3d45679925a6a247 /src
parentc9e9509846b85ce63f0588b937e7e01cdbd45df9 (diff)
parent5f5fccfb40526dbb4e0b4faa7ff5e66d6cb43672 (diff)
downloadrabbitmq-server-git-27ed8c153c83be8086e299e5f27ce03d129f3f79.tar.gz
Merge pull request #2277 from rabbitmq/always-handle-config-files-with-cuttlefish
Always handle config files with Cuttlefish
Diffstat (limited to 'src')
-rw-r--r--src/rabbit_config.erl79
1 files changed, 13 insertions, 66 deletions
diff --git a/src/rabbit_config.erl b/src/rabbit_config.erl
index 573a972c68..1198035a7a 100644
--- a/src/rabbit_config.erl
+++ b/src/rabbit_config.erl
@@ -1,49 +1,30 @@
-module(rabbit_config).
-export([
- schema_dir/0,
config_files/0,
get_advanced_config/0
]).
+-export([schema_dir/0]).
+-deprecated([{schema_dir, 0, eventually}]).
+
-export_type([config_location/0]).
-type config_location() :: string().
-%% we support both the classic Erlang term
-%% config file (rabbitmq.config) as well as rabbitmq.conf
-legacy_erlang_term_config_used() ->
- case get_prelaunch_config_state() of
- #{config_type := erlang,
- config_advanced_file := undefined} ->
- true;
- _ ->
- false
- end.
-
get_confs() ->
case get_prelaunch_config_state() of
- #{config_files := Confs} ->
- [ filename:rootname(Conf, ".conf") ++ ".conf"
- || Conf <- Confs ];
- _ ->
- []
+ #{config_files := Confs} -> Confs;
+ _ -> []
end.
schema_dir() ->
- case init:get_argument(conf_schema_dir) of
- {ok, SchemaDir} -> SchemaDir;
- _ ->
- case code:priv_dir(rabbit) of
- {error, bad_name} -> filename:join([".", "priv", "schema"]);
- PrivDir -> filename:join([PrivDir, "schema"])
- end
- end.
+ undefined.
get_advanced_config() ->
case get_prelaunch_config_state() of
%% There can be only one advanced.config
- #{config_advanced_file := FileName} ->
+ #{config_advanced_file := FileName} when FileName =/= undefined ->
case rabbit_file:is_file(FileName) of
true -> FileName;
false -> none
@@ -53,47 +34,13 @@ get_advanced_config() ->
-spec config_files() -> [config_location()].
config_files() ->
- case legacy_erlang_term_config_used() of
- true ->
- case get_prelaunch_config_state() of
- #{config_files := Files} ->
- [ filename:absname(filename:rootname(File) ++ ".config")
- || File <- Files];
- _ ->
- case config_setting() of
+ ConfFiles = [filename:absname(File) || File <- get_confs(),
+ filelib:is_regular(File)],
+ AdvancedFiles = case get_advanced_config() of
none -> [];
- File -> [filename:absname(filename:rootname(File, ".config") ++ ".config")
- ++
- " (not found)"]
- end
- end;
- false ->
- ConfFiles = [filename:absname(File) || File <- get_confs(),
- filelib:is_regular(File)],
- AdvancedFiles = case get_advanced_config() of
- none -> [];
- FileName -> [filename:absname(FileName)]
- end,
- AdvancedFiles ++ ConfFiles
-
- end.
+ FileName -> [filename:absname(FileName)]
+ end,
+ AdvancedFiles ++ ConfFiles.
get_prelaunch_config_state() ->
rabbit_prelaunch_conf:get_config_state().
-
-%% 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 application:get_env(rabbitmq_prelaunch, context) of
- #{main_config_file := File2} -> File2;
- _ -> none
- end
- end.