fix(retainer): fix that EMQX can't start when the retainer is disabled
This commit is contained in:
parent
2943cbc261
commit
de36b77261
|
@ -348,16 +348,12 @@ enable_retainer(
|
|||
#{context_id := ContextId} = State,
|
||||
#{
|
||||
msg_clear_interval := ClearInterval,
|
||||
backend := BackendCfg,
|
||||
flow_control := FlowControl
|
||||
backend := BackendCfg
|
||||
}
|
||||
) ->
|
||||
NewContextId = ContextId + 1,
|
||||
Context = create_resource(new_context(NewContextId), BackendCfg),
|
||||
load(Context),
|
||||
emqx_limiter_server:add_bucket(
|
||||
?APP, internal, maps:get(batch_deliver_limiter, FlowControl, undefined)
|
||||
),
|
||||
State#{
|
||||
enable := true,
|
||||
context_id := NewContextId,
|
||||
|
@ -373,7 +369,6 @@ disable_retainer(
|
|||
} = State
|
||||
) ->
|
||||
unload(),
|
||||
emqx_limiter_server:del_bucket(?APP, internal),
|
||||
ok = close_resource(Context),
|
||||
State#{
|
||||
enable := false,
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
|
||||
-behaviour(application).
|
||||
|
||||
-include("emqx_retainer.hrl").
|
||||
|
||||
-export([
|
||||
start/2,
|
||||
stop/1
|
||||
|
@ -25,8 +27,19 @@
|
|||
|
||||
start(_Type, _Args) ->
|
||||
ok = emqx_retainer_mnesia_cli:load(),
|
||||
init_bucket(),
|
||||
emqx_retainer_sup:start_link().
|
||||
|
||||
stop(_State) ->
|
||||
ok = emqx_retainer_mnesia_cli:unload(),
|
||||
delete_bucket(),
|
||||
ok.
|
||||
|
||||
init_bucket() ->
|
||||
#{flow_control := FlowControl} = emqx:get_config([retainer]),
|
||||
emqx_limiter_server:add_bucket(
|
||||
?APP, internal, maps:get(batch_deliver_limiter, FlowControl, undefined)
|
||||
).
|
||||
|
||||
delete_bucket() ->
|
||||
emqx_limiter_server:del_bucket(?APP, internal).
|
||||
|
|
Loading…
Reference in New Issue