Просмотр исходного кода

fix(system_monitor): Fix conditional start

k32 4 лет назад
Родитель
Сommit
5a1b18ae86
4 измененных файлов с 8 добавлено и 7 удалено
  1. 1 0
      apps/emqx/src/emqx_schema.erl
  2. 5 5
      apps/emqx_machine/src/emqx_machine.erl
  3. 1 1
      mix.exs
  4. 1 1
      rebar.config.erl

+ 1 - 0
apps/emqx/src/emqx_schema.erl

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

+ 5 - 5
apps/emqx_machine/src/emqx_machine.erl

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

+ 1 - 1
mix.exs

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

+ 1 - 1
rebar.config.erl

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