summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniil Fedotov <dfedotov@pivotal.io>2017-05-04 13:46:19 +0100
committerDaniil Fedotov <dfedotov@pivotal.io>2017-05-04 13:46:19 +0100
commit0bd4b78b3540c65648563714239d2a270c9816a4 (patch)
tree7a9c4437e22195903601dc2fdf433abdad7fbfac
parent02669ff2978349fbc4accb34e69d8c3fd689e94c (diff)
downloadrabbitmq-server-git-0bd4b78b3540c65648563714239d2a270c9816a4.tar.gz
Reload apps on config update.
Configuration update requires applications to be unloaded. Some of the rabbit dependencies are loaded on VM boot, so they should be unloaded before config update. Applications which are already running during config update cannot be unloaded (e.g. kernel) and warning should be reported that config cannot be applied to these applications
-rw-r--r--priv/schema/rabbitmq.schema7
-rw-r--r--src/rabbit_config.erl38
2 files changed, 37 insertions, 8 deletions
diff --git a/priv/schema/rabbitmq.schema b/priv/schema/rabbitmq.schema
index 6f3f42e4ed..fab07baeb4 100644
--- a/priv/schema/rabbitmq.schema
+++ b/priv/schema/rabbitmq.schema
@@ -999,7 +999,7 @@ fun(Conf) ->
[{lager_console_backend, ConsoleLevel}];
false -> []
end,
- FileHandler = case cuttlefish:conf_get("log.file", Conf, false) of
+ FileHandler = case cuttlefish:conf_get("log.file", Conf, undefined) of
false -> [];
File ->
FileLevel = cuttlefish:conf_get("log.file.level", Conf, info),
@@ -1010,6 +1010,11 @@ fun(Conf) ->
{level, FileLevel},
{date, RotationDate},
{size, RotationSize},
+ {formatter_config,
+ [date, " ", time, " ", color,
+ "[", severity, "] ",
+ {pid, ""},
+ " ", message, "\n"]},
{count, RotationCount}]}]
end,
SyslogHandler = case cuttlefish:conf_get("log.syslog", Conf, false) of
diff --git a/src/rabbit_config.erl b/src/rabbit_config.erl
index 67e7523ec0..9e70898c82 100644
--- a/src/rabbit_config.erl
+++ b/src/rabbit_config.erl
@@ -33,10 +33,10 @@ prepare_and_use_config() ->
legacy_erlang_term_config_used() ->
case init:get_argument(config) of
error -> false;
- {ok, [Config | _]} ->
+ {ok, [Config | _]} ->
ConfigFile = Config ++ ".config",
- rabbit_file:is_file(ConfigFile)
- andalso
+ rabbit_file:is_file(ConfigFile)
+ andalso
get_advanced_config() == none
end.
@@ -66,10 +66,34 @@ prepare_config(Configs) ->
end.
update_app_config(ConfigFile) ->
- ok = application_controller:change_application_data([], [ConfigFile]).
+ RunningApps = [ App || {App, _, _} <- application:which_applications() ],
+ LoadedApps = [ App || {App, _, _} <- application:loaded_applications() ],
+ {ok, [Config]} = file:consult(ConfigFile),
+ %% For application config to be updated, applications should
+ %% be unloaded first.
+ %% If an application is already running, print an error.
+ lists:foreach(fun({App, _Config}) ->
+ case lists:member(App, RunningApps) of
+ true ->
+ io:format(standard_error,
+ "~nUnable to update config for app ~p from *.conf file."
+ " App is already running. Use advanced.config instead.~n",
+ [App]);
+ false ->
+ case lists:member(App, LoadedApps) of
+ true -> application:unload(App);
+ false -> ok
+ end
+ end
+ end,
+ Config),
+ ok = application_controller:change_application_data([], [ConfigFile]),
+ %% Make sure to load all the applications we're unloaded
+ lists:foreach(fun(App) -> application:load(App) end, LoadedApps),
+ ok.
generate_config_file(ConfFiles, ConfDir, ScriptDir) ->
- generate_config_file(ConfFiles, ConfDir, ScriptDir,
+ generate_config_file(ConfFiles, ConfDir, ScriptDir,
schema_dir(), get_advanced_config()).
@@ -145,8 +169,8 @@ config_files() ->
{ok, Files} -> [Abs(File, ".config") || [File] <- Files];
error -> case config_setting() of
none -> [];
- File -> [Abs(File, ".config")
- ++
+ File -> [Abs(File, ".config")
+ ++
" (not found)"]
end
end;