fix(gw): load emqx applications before hocon configs checking
This commit is contained in:
parent
9712aad7a8
commit
f2fae16d3b
|
@ -45,7 +45,7 @@ load_default_gateway_applications() ->
|
|||
fun(Def) ->
|
||||
load_gateway_application(Def)
|
||||
end,
|
||||
emqx_gateway_utils:find_gateway_definations()
|
||||
emqx_gateway_utils:find_gateway_definitions()
|
||||
).
|
||||
|
||||
load_gateway_application(
|
||||
|
|
|
@ -75,7 +75,7 @@ fields(gateway) ->
|
|||
}
|
||||
)}
|
||||
end,
|
||||
emqx_gateway_utils:find_gateway_definations()
|
||||
emqx_gateway_utils:find_gateway_definitions()
|
||||
);
|
||||
fields(clientinfo_override) ->
|
||||
[
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
listener_chain/3,
|
||||
make_deprecated_paths/1,
|
||||
make_compatible_schema/2,
|
||||
find_gateway_definations/0
|
||||
find_gateway_definitions/0
|
||||
]).
|
||||
|
||||
-export([stringfy/1]).
|
||||
|
@ -564,8 +564,8 @@ make_compatible_schema2(Path, SchemaFun) ->
|
|||
Schema
|
||||
).
|
||||
|
||||
-spec find_gateway_definations() -> list(gateway_def()).
|
||||
find_gateway_definations() ->
|
||||
-spec find_gateway_definitions() -> list(gateway_def()).
|
||||
find_gateway_definitions() ->
|
||||
lists:flatten(
|
||||
lists:map(
|
||||
fun(App) ->
|
||||
|
|
16
bin/nodetool
16
bin/nodetool
|
@ -362,6 +362,20 @@ add_libs_dir() ->
|
|||
add_lib_dir(RootDir, Name, Vsn) ->
|
||||
LibDir = filename:join([RootDir, lib, atom_to_list(Name) ++ "-" ++ Vsn, ebin]),
|
||||
case code:add_patha(LibDir) of
|
||||
true -> ok;
|
||||
true ->
|
||||
%% load all applications into application controller, before performing
|
||||
%% the configuration check of HOCON
|
||||
%%
|
||||
%% It helps to implement the feature of dynamically searching schema.
|
||||
%% See `emqx_gateway_schema:fields(gateway)`
|
||||
is_emqx_application(Name) andalso application:load(Name),
|
||||
ok;
|
||||
{error, _} -> error(LibDir)
|
||||
end.
|
||||
|
||||
is_emqx_application(Name) when is_atom(Name) ->
|
||||
is_emqx_application(atom_to_list(Name));
|
||||
is_emqx_application("emqx_" ++ _Rest) ->
|
||||
true;
|
||||
is_emqx_application(_) ->
|
||||
false.
|
||||
|
|
Loading…
Reference in New Issue