fix(exhook): set trap_exit flag
This commit is contained in:
parent
b3db4d0f7c
commit
1e4ca14476
|
@ -101,6 +101,7 @@ call(Pid, Req) ->
|
|||
%%--------------------------------------------------------------------
|
||||
|
||||
init([Servers, AutoReconnect, ReqOpts]) ->
|
||||
process_flag(trap_exit, true),
|
||||
%% XXX: Due to the ExHook Module in the enterprise,
|
||||
%% this process may start multiple times and they will share this table
|
||||
try
|
||||
|
@ -182,11 +183,11 @@ handle_info({timeout, _Ref, {reload, Name}}, State) ->
|
|||
handle_info(_Info, State) ->
|
||||
{noreply, State}.
|
||||
|
||||
terminate(_Reason, State = #state{stopped = Stopped}) ->
|
||||
terminate(_Reason, State = #state{running = Running}) ->
|
||||
_ = maps:fold(fun(Name, _, AccIn) ->
|
||||
{ok, NAccIn} = do_unload_server(Name, AccIn),
|
||||
NAccIn
|
||||
end, State, Stopped),
|
||||
end, State, Running),
|
||||
_ = unload_exhooks(),
|
||||
ok.
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#{ id => Mod
|
||||
, start => {Mod, start_link, Args}
|
||||
, type => Type
|
||||
, shutdown => 15000
|
||||
}
|
||||
).
|
||||
|
||||
|
|
|
@ -52,17 +52,12 @@ set_special_cfgs(emqx_exhook) ->
|
|||
t_noserver_nohook(_) ->
|
||||
emqx_exhook:disable(default),
|
||||
?assertEqual([], ets:tab2list(emqx_hooks)),
|
||||
|
||||
Opts = proplists:get_value(
|
||||
default,
|
||||
application:get_env(emqx_exhook, servers, [])
|
||||
),
|
||||
ok = emqx_exhook:enable(default, Opts),
|
||||
ok = emqx_exhook:enable(default),
|
||||
?assertNotEqual([], ets:tab2list(emqx_hooks)).
|
||||
|
||||
t_cli_list(_) ->
|
||||
meck_print(),
|
||||
?assertEqual( [[emqx_exhook_server:format(Svr) || Svr <- emqx_exhook:list()]]
|
||||
?assertEqual( [[emqx_exhook_server:format(emqx_exhook_mngr:server(Name)) || Name <- emqx_exhook:list()]]
|
||||
, emqx_exhook_cli:cli(["server", "list"])
|
||||
),
|
||||
unmeck_print().
|
||||
|
@ -71,7 +66,7 @@ t_cli_enable_disable(_) ->
|
|||
meck_print(),
|
||||
?assertEqual([already_started], emqx_exhook_cli:cli(["server", "enable", "default"])),
|
||||
?assertEqual(ok, emqx_exhook_cli:cli(["server", "disable", "default"])),
|
||||
?assertEqual([], emqx_exhook_cli:cli(["server", "list"])),
|
||||
?assertEqual([["name=default, hooks=#{}, active=false"]], emqx_exhook_cli:cli(["server", "list"])),
|
||||
|
||||
?assertEqual([not_running], emqx_exhook_cli:cli(["server", "disable", "default"])),
|
||||
?assertEqual(ok, emqx_exhook_cli:cli(["server", "enable", "default"])),
|
||||
|
|
Loading…
Reference in New Issue