Merge pull request #9777 from zmstone/0116-refactor-config_files-is-readonly

refactor: config_files is a readonly config
This commit is contained in:
zhongwencool 2023-01-17 20:32:39 +08:00 committed by GitHub
commit 9f80eb2497
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 40 additions and 43 deletions

View File

@ -128,6 +128,7 @@ all() ->
init_per_suite(Config) -> init_per_suite(Config) ->
application:set_env(ekka, strict_mode, true), application:set_env(ekka, strict_mode, true),
emqx_common_test_helpers:boot_modules(all),
emqx_common_test_helpers:start_apps([]), emqx_common_test_helpers:start_apps([]),
Config. Config.

View File

@ -24,19 +24,23 @@
all() -> emqx_common_test_helpers:all(?MODULE). all() -> emqx_common_test_helpers:all(?MODULE).
t_is_enabled(_) -> t_is_enabled(_) ->
ok = application:set_env(emqx, boot_modules, all), try
?assert(emqx_boot:is_enabled(router)), ok = application:set_env(emqx, boot_modules, all),
?assert(emqx_boot:is_enabled(broker)), ?assert(emqx_boot:is_enabled(router)),
?assert(emqx_boot:is_enabled(listeners)), ?assert(emqx_boot:is_enabled(broker)),
ok = application:set_env(emqx, boot_modules, [router]), ?assert(emqx_boot:is_enabled(listeners)),
?assert(emqx_boot:is_enabled(router)), ok = application:set_env(emqx, boot_modules, [router]),
?assertNot(emqx_boot:is_enabled(broker)), ?assert(emqx_boot:is_enabled(router)),
?assertNot(emqx_boot:is_enabled(listeners)), ?assertNot(emqx_boot:is_enabled(broker)),
ok = application:set_env(emqx, boot_modules, [router, broker]), ?assertNot(emqx_boot:is_enabled(listeners)),
?assert(emqx_boot:is_enabled(router)), ok = application:set_env(emqx, boot_modules, [router, broker]),
?assert(emqx_boot:is_enabled(broker)), ?assert(emqx_boot:is_enabled(router)),
?assertNot(emqx_boot:is_enabled(listeners)), ?assert(emqx_boot:is_enabled(broker)),
ok = application:set_env(emqx, boot_modules, [router, broker, listeners]), ?assertNot(emqx_boot:is_enabled(listeners)),
?assert(emqx_boot:is_enabled(router)), ok = application:set_env(emqx, boot_modules, [router, broker, listeners]),
?assert(emqx_boot:is_enabled(broker)), ?assert(emqx_boot:is_enabled(router)),
?assert(emqx_boot:is_enabled(listeners)). ?assert(emqx_boot:is_enabled(broker)),
?assert(emqx_boot:is_enabled(listeners))
after
application:set_env(emqx, boot_modules, all)
end.

View File

@ -456,19 +456,6 @@ the old dir should be deleted first.<br/>
} }
} }
node_config_files {
desc {
en: """List of configuration files that are read during startup. The order is
significant: later configuration files override the previous ones.
"""
zh: """启动时读取的配置文件列表。后面的配置文件项覆盖前面的文件。"""
}
label {
en: "Config Files"
zh: "配置文件"
}
}
node_global_gc_interval { node_global_gc_interval {
desc { desc {
en: """Periodic garbage collection interval. Set to <code>disabled</code> to have it disabled.""" en: """Periodic garbage collection interval. Set to <code>disabled</code> to have it disabled."""

View File

@ -466,9 +466,9 @@ fields("node") ->
hoconsc:array(string()), hoconsc:array(string()),
#{ #{
mapping => "emqx.config_files", mapping => "emqx.config_files",
default => undefined, hidden => true,
'readOnly' => true, required => false,
desc => ?DESC(node_config_files) 'readOnly' => true
} }
)}, )},
{"global_gc_interval", {"global_gc_interval",
@ -1037,17 +1037,13 @@ metrics_enabled(disabled) -> [].
tr_default_config_driver(Conf) -> tr_default_config_driver(Conf) ->
conf_get("rpc.driver", Conf). conf_get("rpc.driver", Conf).
tr_config_files(Conf) -> tr_config_files(_Conf) ->
case conf_get("emqx.config_files", Conf) of case os:getenv("EMQX_ETC_DIR") of
[_ | _] = Files -> false ->
Files; %% testing, or running emqx app as deps
_ -> [filename:join([code:lib_dir(emqx), "etc", "emqx.conf"])];
case os:getenv("EMQX_ETC_DIR") of Dir ->
false -> [filename:join([Dir, "emqx.conf"])]
[filename:join([code:lib_dir(emqx), "etc", "emqx.conf"])];
Dir ->
[filename:join([Dir, "emqx.conf"])]
end
end. end.
tr_cluster_override_conf_file(Conf) -> tr_cluster_override_conf_file(Conf) ->

View File

@ -0,0 +1,5 @@
Reload overriding configs after boot.
Prior to this change, two configs were allow to change from dashboard, but will not take effect after reboot:
* Logging (such as level)
* Prometheus configs

View File

@ -0,0 +1,4 @@
启动后重新加载一些重载配置项。
在此修复前,下面两个配置项允许从 Dashboard 控制台修改,但是在重启后无法生效:
* 日志 (例如日志级别)
* Prometheus 配置