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
This commit is contained in:
parent
da988060c5
commit
fdb3e75284
|
@ -459,7 +459,7 @@
|
||||||
# Kernel section
|
# Kernel section
|
||||||
# ======================================
|
# ======================================
|
||||||
|
|
||||||
# kernel.net_ticktime = 60
|
# net_ticktime = 60
|
||||||
|
|
||||||
## ----------------------------------------------------------------------------
|
## ----------------------------------------------------------------------------
|
||||||
## RabbitMQ Management Plugin
|
## RabbitMQ Management Plugin
|
||||||
|
|
|
@ -1150,6 +1150,14 @@ end}.
|
||||||
{datatype, {enum, [debug, info, notice, warning, error, critical, alert, emergency, none]}}
|
{datatype, {enum, [debug, info, notice, warning, error, critical, alert, emergency, none]}}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
|
% ==========================
|
||||||
|
% Kernel section
|
||||||
|
% ==========================
|
||||||
|
|
||||||
|
{mapping, "net_ticktime", "kernel.net_ticktime",[
|
||||||
|
{datatype, [integer]}
|
||||||
|
]}.
|
||||||
|
|
||||||
% ===============================
|
% ===============================
|
||||||
% Validators
|
% Validators
|
||||||
% ===============================
|
% ===============================
|
||||||
|
|
|
@ -72,13 +72,10 @@ update_app_config(ConfigFile) ->
|
||||||
%% For application config to be updated, applications should
|
%% For application config to be updated, applications should
|
||||||
%% be unloaded first.
|
%% be unloaded first.
|
||||||
%% If an application is already running, print an error.
|
%% 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
|
case lists:member(App, RunningApps) of
|
||||||
true ->
|
true ->
|
||||||
io:format(standard_error,
|
maybe_print_warning_for_running_app(App, AppConfig);
|
||||||
"~nUnable to update config for app ~p from *.conf file."
|
|
||||||
" App is already running. Use advanced.config instead.~n",
|
|
||||||
[App]);
|
|
||||||
false ->
|
false ->
|
||||||
case lists:member(App, LoadedApps) of
|
case lists:member(App, LoadedApps) of
|
||||||
true -> application:unload(App);
|
true -> application:unload(App);
|
||||||
|
@ -87,11 +84,44 @@ update_app_config(ConfigFile) ->
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
Config),
|
Config),
|
||||||
|
maybe_set_net_ticktime(proplists:get_value(kernel, Config)),
|
||||||
ok = application_controller:change_application_data([], [ConfigFile]),
|
ok = application_controller:change_application_data([], [ConfigFile]),
|
||||||
%% Make sure to load all the applications we're unloaded
|
%% Make sure to load all the applications we're unloaded
|
||||||
lists:foreach(fun(App) -> application:load(App) end, LoadedApps),
|
lists:foreach(fun(App) -> application:load(App) end, LoadedApps),
|
||||||
ok.
|
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) ->
|
||||||
generate_config_file(ConfFiles, ConfDir, ScriptDir,
|
generate_config_file(ConfFiles, ConfDir, ScriptDir,
|
||||||
schema_dir(), get_advanced_config()).
|
schema_dir(), get_advanced_config()).
|
||||||
|
|
|
@ -528,5 +528,11 @@ credential_validator.regexp = ^abc\\d+",
|
||||||
[{rabbit, [
|
[{rabbit, [
|
||||||
{delegate_count, 64}
|
{delegate_count, 64}
|
||||||
]}],
|
]}],
|
||||||
|
[]},
|
||||||
|
{kernel_net_ticktime,
|
||||||
|
"net_ticktime = 20",
|
||||||
|
[{kernel, [
|
||||||
|
{net_ticktime, 20}
|
||||||
|
]}],
|
||||||
[]}
|
[]}
|
||||||
].
|
].
|
||||||
|
|
Loading…
Reference in New Issue