diff options
| author | Arnaud Cogoluègnes <acogoluegnes@gmail.com> | 2018-02-22 11:25:45 +0100 |
|---|---|---|
| committer | Arnaud Cogoluègnes <acogoluegnes@gmail.com> | 2018-02-22 14:50:05 +0100 |
| commit | be6aedf52a96644345626bfc84e09ff9532a0383 (patch) | |
| tree | ef354bd12c5ef41456347631360d02d97d2dfb4f /src | |
| parent | 54d856115ce767e9a993e6520a85cb058b86bc02 (diff) | |
| download | rabbitmq-server-git-be6aedf52a96644345626bfc84e09ff9532a0383.tar.gz | |
Support kernel.net_ticktime in Cuttlefish configuration
net_ticktime, if present in the .conf file, is set up with
net_kernel:set_net_ticktime/1 before the configuration
of the .conf is applied to the other applications. The kernel
is already running when the configuration is applied, so net_ticktime
is set in a specific way.
[#155393098]
Fixes #1522
(cherry picked from commit fdb3e7528431491e5d8718ef65e28c82efeb898b)
Diffstat (limited to 'src')
| -rw-r--r-- | src/rabbit_config.erl | 40 |
1 files changed, 35 insertions, 5 deletions
diff --git a/src/rabbit_config.erl b/src/rabbit_config.erl index a3f7d19136..7333a4157a 100644 --- a/src/rabbit_config.erl +++ b/src/rabbit_config.erl @@ -72,13 +72,10 @@ update_app_config(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}) -> + lists:foreach(fun({App, AppConfig}) -> 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]); + maybe_print_warning_for_running_app(App, AppConfig); false -> case lists:member(App, LoadedApps) of true -> application:unload(App); @@ -87,11 +84,44 @@ update_app_config(ConfigFile) -> end end, Config), + maybe_set_net_ticktime(proplists:get_value(kernel, 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. +maybe_print_warning_for_running_app(kernel, Config) -> + ConfigWithoutSupportedEntry = proplists:delete(net_ticktime, Config), + case length(ConfigWithoutSupportedEntry) > 0 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", [kernel]); + false -> ok + end; +maybe_print_warning_for_running_app(App, _Config) -> + io:format(standard_error, + "~nUnable to update config for app ~p from *.conf file." + " App is already running. Use advanced.config instead.~n", + [App]). + +maybe_set_net_ticktime(undefined) -> + ok; +maybe_set_net_ticktime(KernelConfig) -> + case proplists:get_value(net_ticktime, KernelConfig) of + undefined -> + ok; + NetTickTime -> + case net_kernel:set_net_ticktime(NetTickTime) of + {ongoing_change_to, NewNetTicktime} -> + io:format(standard_error, + "~nCouldn't set net_ticktime to ~p " + "as net_kernel is busy changing net_ticktime to ~p seconds ~n", + [NetTickTime, NewNetTicktime]); + _ -> + ok + end + end. + generate_config_file(ConfFiles, ConfDir, ScriptDir) -> generate_config_file(ConfFiles, ConfDir, ScriptDir, schema_dir(), get_advanced_config()). |
