fix(emqx_conf): call clean callback before ekka stop

This commit is contained in:
firest 2023-07-03 17:14:32 +08:00
parent 460ea0e957
commit afabdc3440
1 changed files with 20 additions and 1 deletions

View File

@ -282,7 +282,7 @@ on_mria_stop(_) ->
%% @private %% @private
init([Node, RetryMs]) -> init([Node, RetryMs]) ->
mria:register_callback(stop, fun ?MODULE:on_mria_stop/1), register_mria_stop_cb(fun ?MODULE:on_mria_stop/1),
{ok, _} = mnesia:subscribe({table, ?CLUSTER_MFA, simple}), {ok, _} = mnesia:subscribe({table, ?CLUSTER_MFA, simple}),
State = #{node => Node, retry_interval => RetryMs, is_leaving => false}, State = #{node => Node, retry_interval => RetryMs, is_leaving => false},
%% The init transaction ID is set in emqx_conf_app after %% The init transaction ID is set in emqx_conf_app after
@ -643,3 +643,22 @@ do_wait_for_emqx_ready2(N) ->
timer:sleep(100), timer:sleep(100),
do_wait_for_emqx_ready2(N - 1) do_wait_for_emqx_ready2(N - 1)
end. end.
register_mria_stop_cb(Callback) ->
case mria_config:callback(stop) of
undefined ->
mria:register_callback(stop, Callback);
{ok, Previous} ->
mria:register_callback(
stop,
fun(Arg) ->
Callback(Arg),
case erlang:fun_info(Previous, arity) of
{arity, 0} ->
Previous();
{arity, 1} ->
Previous(Arg)
end
end
)
end.