Merge pull request #6940 from k32/fix-sysmon-start

fix(system_monitor): Fix conditional start
This commit is contained in:
k32 2022-02-08 13:33:37 +01:00 committed by GitHub
commit 72dc7276ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 7 deletions

View File

@ -1033,6 +1033,7 @@ in the VM exceeds this value"
sc(string(), sc(string(),
#{ mapping => "system_monitor.db_hostname" #{ mapping => "system_monitor.db_hostname"
, desc => "Hostname of the PostgreSQL database that collects the data points" , desc => "Hostname of the PostgreSQL database that collects the data points"
, default => ""
}) })
} }
, {"db_port", , {"db_port",

View File

@ -64,13 +64,13 @@ start_sysmon() ->
application:set_env(system_monitor, node_status_fun, {?MODULE, node_status}), application:set_env(system_monitor, node_status_fun, {?MODULE, node_status}),
application:set_env(system_monitor, status_checks, [{?MODULE, update_vips, false, 10}]), application:set_env(system_monitor, status_checks, [{?MODULE, update_vips, false, 10}]),
case application:get_env(system_monitor, db_hostname) of case application:get_env(system_monitor, db_hostname) of
undefined -> {ok, [_|_]} ->
%% If there is no sink for the events, there is no reason
%% to run system_monitor_top, ignore it:
ok;
_ ->
application:set_env(system_monitor, callback_mod, system_monitor_pg), application:set_env(system_monitor, callback_mod, system_monitor_pg),
_ = application:ensure_all_started(system_monitor, temporary), _ = application:ensure_all_started(system_monitor, temporary),
ok;
_ ->
%% If there is no sink for the events, there is no reason
%% to run system_monitor_top, ignore start
ok ok
end. end.

View File

@ -176,7 +176,7 @@ defmodule EMQXUmbrella.MixProject do
emqx_plugin_libs: :load, emqx_plugin_libs: :load,
esasl: :load, esasl: :load,
observer_cli: :permanent, observer_cli: :permanent,
system_monitor: :permanent, system_monitor: :load,
emqx_http_lib: :permanent, emqx_http_lib: :permanent,
emqx_resource: :permanent, emqx_resource: :permanent,
emqx_connector: :permanent, emqx_connector: :permanent,

View File

@ -302,7 +302,7 @@ relx_apps(ReleaseType, Edition) ->
, {emqx_plugin_libs, load} , {emqx_plugin_libs, load}
, {esasl, load} , {esasl, load}
, observer_cli , observer_cli
, system_monitor , {system_monitor, load} % started by emqx_machine
, emqx_http_lib , emqx_http_lib
, emqx_resource , emqx_resource
, emqx_connector , emqx_connector