Skip to content

Commit fbc15fa

Browse files
committed
rabbitmq_prelaunch: erl(1) init flags have precedence over configuration
[Why] We want that configuration settings passed on the command line take precedence over settings in configuration files. [How] We query the erl(1) init flags and use it to filter out any settings from the configuration file already set on the command line.
1 parent 497ed9b commit fbc15fa

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

deps/rabbit/apps/rabbitmq_prelaunch/src/rabbit_prelaunch_conf.erl

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,31 @@ set_default_config() ->
136136
]}
137137
| OsirisConfig
138138
],
139-
apply_erlang_term_based_config(Config).
139+
%% Don't apply any defaults for values already set in the init flags.
140+
Config1 = filter_init_args(Config),
141+
apply_erlang_term_based_config(Config1).
142+
143+
filter_init_args(Config) ->
144+
lists:filtermap(
145+
fun({App, Vars}) ->
146+
case init:get_argument(App) of
147+
{ok, Args} ->
148+
Keys = [rabbit_data_coercion:to_atom(KeyName) ||
149+
[KeyName, _ValueExpr] <- Args],
150+
Vars1 = lists:filter(
151+
fun({Key, _Value}) ->
152+
not lists:member(Key, Keys)
153+
end, Vars),
154+
case Vars1 of
155+
[] ->
156+
false;
157+
_ ->
158+
{true, {App, Vars1}}
159+
end;
160+
error ->
161+
true
162+
end
163+
end, Config).
140164

141165
osiris_log(debug, Fmt, Args) ->
142166
?LOG_DEBUG(Fmt, Args,

0 commit comments

Comments
 (0)