fix: catch errors when load bridges
This commit is contained in:
parent
8518e71db1
commit
dd099137f0
|
@ -508,10 +508,10 @@ handle_info(Info, State) ->
|
||||||
|
|
||||||
terminate(Reason, _State) ->
|
terminate(Reason, _State) ->
|
||||||
case Reason of
|
case Reason of
|
||||||
normal ->
|
|
||||||
ok;
|
|
||||||
{shutdown, _} ->
|
{shutdown, _} ->
|
||||||
ok;
|
ok;
|
||||||
|
Reason when Reason == normal; Reason == shutdown ->
|
||||||
|
ok;
|
||||||
Other ->
|
Other ->
|
||||||
?SLOG(error, #{
|
?SLOG(error, #{
|
||||||
msg => "emqx_authentication_terminating",
|
msg => "emqx_authentication_terminating",
|
||||||
|
|
|
@ -55,15 +55,7 @@ load() ->
|
||||||
fun({Type, NamedConf}) ->
|
fun({Type, NamedConf}) ->
|
||||||
lists:foreach(
|
lists:foreach(
|
||||||
fun({Name, Conf}) ->
|
fun({Name, Conf}) ->
|
||||||
_Res = emqx_bridge_resource:create(Type, Name, Conf, Opts),
|
safe_load_bridge(Type, Name, Conf, Opts)
|
||||||
?tp(
|
|
||||||
emqx_bridge_loaded,
|
|
||||||
#{
|
|
||||||
type => Type,
|
|
||||||
name => Name,
|
|
||||||
res => _Res
|
|
||||||
}
|
|
||||||
)
|
|
||||||
end,
|
end,
|
||||||
maps:to_list(NamedConf)
|
maps:to_list(NamedConf)
|
||||||
)
|
)
|
||||||
|
@ -71,6 +63,29 @@ load() ->
|
||||||
maps:to_list(Bridges)
|
maps:to_list(Bridges)
|
||||||
).
|
).
|
||||||
|
|
||||||
|
safe_load_bridge(Type, Name, Conf, Opts) ->
|
||||||
|
try
|
||||||
|
_Res = emqx_bridge_resource:create(Type, Name, Conf, Opts),
|
||||||
|
?tp(
|
||||||
|
emqx_bridge_loaded,
|
||||||
|
#{
|
||||||
|
type => Type,
|
||||||
|
name => Name,
|
||||||
|
res => _Res
|
||||||
|
}
|
||||||
|
)
|
||||||
|
catch
|
||||||
|
Err:Reason:ST ->
|
||||||
|
?SLOG(error, #{
|
||||||
|
msg => "load_bridge_failed",
|
||||||
|
type => Type,
|
||||||
|
name => Name,
|
||||||
|
error => Err,
|
||||||
|
reason => Reason,
|
||||||
|
stacktrace => ST
|
||||||
|
})
|
||||||
|
end.
|
||||||
|
|
||||||
load_hook() ->
|
load_hook() ->
|
||||||
Bridges = emqx:get_config([bridges], #{}),
|
Bridges = emqx:get_config([bridges], #{}),
|
||||||
load_hook(Bridges).
|
load_hook(Bridges).
|
||||||
|
|
|
@ -571,6 +571,9 @@ pick_bridges_by_id(Type, Name, BridgesAllNodes) ->
|
||||||
[] ->
|
[] ->
|
||||||
?SLOG(warning, #{
|
?SLOG(warning, #{
|
||||||
msg => "bridge_inconsistent_in_cluster",
|
msg => "bridge_inconsistent_in_cluster",
|
||||||
|
reason => not_found,
|
||||||
|
type => Type,
|
||||||
|
name => Name,
|
||||||
bridge => emqx_bridge_resource:bridge_id(Type, Name)
|
bridge => emqx_bridge_resource:bridge_id(Type, Name)
|
||||||
}),
|
}),
|
||||||
Acc
|
Acc
|
||||||
|
|
Loading…
Reference in New Issue