Browse Source

chore(mix): fix app dependencies and reboot apps (emqx_conf)

While declaring `emqx_conf` as an application dependency of
`emqx_resource` worked for releases, it messed up the startup
relationship during tests.  Since only removing `emqx_conf` from the
`applications` key in `emqx_resource` breaks the list of apps that
need to be rebooted on config changes (since `emqx_conf` is not on any
apps dependencies list, it was not being added to the final
topologically sorted list), we now always add it as a vertex to ensure
its presence there.  This (apparently) makes the rebar3 release, the
mix release and test runs behave normally.
Thales Macedo Garitezi 4 years atrás
parent
commit
11c169501e

+ 6 - 0
apps/emqx_machine/src/emqx_machine_boot.erl

@@ -135,6 +135,12 @@ add_app(G, App, undefined) ->
     ?SLOG(debug, #{msg => "app_is_not_loaded", app => App}),
     %% not loaded
     add_app(G, App, []);
+% We ALWAYS want to add `emqx_conf', even if no other app declare a
+% dependency on it.  Otherwise, emqx may fail to load the config
+% schemas, especially in the test profile.
+add_app(G, App = emqx_conf, []) ->
+    digraph:add_vertex(G, App),
+    ok;
 add_app(_G, _App, []) ->
     ok;
 add_app(G, App, [Dep | Deps]) ->

+ 1 - 1
apps/emqx_machine/test/emqx_machine_SUITE.erl

@@ -43,7 +43,7 @@ init_per_suite(Config) ->
     %%
     application:unload(emqx_authz),
 
-    emqx_common_test_helpers:start_apps([]),
+    emqx_common_test_helpers:start_apps([emqx_conf]),
     Config.
 
 end_per_suite(_Config) ->

+ 1 - 2
apps/emqx_resource/src/emqx_resource.app.src

@@ -9,8 +9,7 @@
     stdlib,
     gproc,
     jsx,
-    emqx,
-    emqx_conf
+    emqx
    ]},
   {env,[]},
   {modules, []},