refactor(emqx_machine): move system_monitor to included_applications

system_monitor has to be found in application (or included_applications)
otherwise dialyzer fails with Unknown function

Adding to 'applications' would cause a deadlock because one
cannot call application:ensure_all_started in the application/2
callback.
This commit is contained in:
Zaiming (Stone) Shi 2023-12-06 15:18:51 +01:00
parent 6b553e37c0
commit 9a6056ff2f
4 changed files with 18 additions and 15 deletions

View File

@ -24,8 +24,15 @@
runtime_tools, runtime_tools,
redbug, redbug,
xmerl, xmerl,
%% has no application/2 callback
{hocon, load}, {hocon, load},
telemetry telemetry,
observer_cli,
covertool,
tools,
observer,
{system_monitor, load},
jq
], ],
%% must always be of type `load' %% must always be of type `load'
common_business_apps => common_business_apps =>
@ -33,11 +40,6 @@
emqx, emqx,
emqx_conf, emqx_conf,
esasl, esasl,
observer_cli,
tools,
covertool,
%% started by emqx_machine
system_monitor,
emqx_utils, emqx_utils,
emqx_durable_storage, emqx_durable_storage,
emqx_http_lib, emqx_http_lib,
@ -79,9 +81,7 @@
emqx_plugins, emqx_plugins,
emqx_opentelemetry, emqx_opentelemetry,
quicer, quicer,
bcrypt, bcrypt
jq,
observer
], ],
%% must always be of type `load' %% must always be of type `load'
ee_business_apps => ee_business_apps =>

View File

@ -6,7 +6,13 @@
{vsn, "0.2.17"}, {vsn, "0.2.17"},
{modules, []}, {modules, []},
{registered, []}, {registered, []},
{applications, [kernel, stdlib, emqx_ctl, system_monitor, covertool]}, {applications, [kernel, stdlib, emqx_ctl, covertool]},
%% system_monitor is loaded but not booted,
%% emqx_machine.erl makes the decision when to start
%% the app after certain config injection.
%% it's a included_application because otherwise dialyzer
%% would report unknown functions
{included_applications, [system_monitor]},
{mod, {emqx_machine_app, []}}, {mod, {emqx_machine_app, []}},
{env, []}, {env, []},
{licenses, ["Apache-2.0"]}, {licenses, ["Apache-2.0"]},

View File

@ -47,7 +47,7 @@ start() ->
os:set_signal(sigterm, handle) os:set_signal(sigterm, handle)
end, end,
ok = set_backtrace_depth(), ok = set_backtrace_depth(),
start_sysmon(), ok = start_sysmon(),
configure_shard_transports(), configure_shard_transports(),
set_mnesia_extra_diagnostic_checks(), set_mnesia_extra_diagnostic_checks(),
emqx_otel_app:configure_otel_deps(), emqx_otel_app:configure_otel_deps(),

View File

@ -36,9 +36,6 @@
%% If any of these applications crash, the entire EMQX node shuts down: %% If any of these applications crash, the entire EMQX node shuts down:
-define(BASIC_PERMANENT_APPS, [mria, ekka, esockd, emqx]). -define(BASIC_PERMANENT_APPS, [mria, ekka, esockd, emqx]).
%% These apps should NOT be (re)started automatically:
-define(EXCLUDED_APPS, [system_monitor, observer_cli, jq]).
%% These apps are optional, they may or may not be present in the %% These apps are optional, they may or may not be present in the
%% release, depending on the build flags: %% release, depending on the build flags:
-define(OPTIONAL_APPS, [bcrypt, observer]). -define(OPTIONAL_APPS, [bcrypt, observer]).
@ -157,7 +154,7 @@ basic_reboot_apps() ->
excluded_apps() -> excluded_apps() ->
%% Optional apps _should_ be (re)started automatically, but only %% Optional apps _should_ be (re)started automatically, but only
%% when they are found in the release: %% when they are found in the release:
?EXCLUDED_APPS ++ [App || App <- ?OPTIONAL_APPS, not is_app(App)]. [App || App <- ?OPTIONAL_APPS, not is_app(App)].
is_app(Name) -> is_app(Name) ->
case application:load(Name) of case application:load(Name) of