refactor(persistent_sessions): don't start session sup when disabled

This commit is contained in:
Tobias Lindahl 2021-10-26 09:54:41 +02:00
parent e3dc9b3f4f
commit 234641ccf4
2 changed files with 21 additions and 20 deletions

View File

@ -26,10 +26,6 @@ start_link() ->
supervisor:start_link({local, ?MODULE}, ?MODULE, []).
init([]) ->
case emqx_persistent_session:is_store_enabled() of
false ->
{ok, {{one_for_all, 0, 1}, []}};
true ->
%% We want this supervisor to own the table for restarts
SessionTab = emqx_session_router:create_init_tab(),
@ -47,8 +43,12 @@ init([]) ->
GCWorker = child_spec(emqx_persistent_session_gc, worker),
{ok, {{one_for_all, 0, 1}, [ResumeSup, SessionRouterPool, GCWorker]}}
end.
Spec = #{ strategy => one_for_all
, intensity => 0
, period => 1
},
{ok, {Spec, [ResumeSup, SessionRouterPool, GCWorker]}}.
child_spec(Mod, worker) ->
#{id => Mod,

View File

@ -68,7 +68,8 @@ init([]) ->
SessionSup = child_spec(emqx_persistent_session_sup, supervisor),
CMSup = child_spec(emqx_cm_sup, supervisor),
SysSup = child_spec(emqx_sys_sup, supervisor),
Children = [KernelSup, SessionSup] ++
Children = [KernelSup] ++
[SessionSup || emqx_persistent_session:is_store_enabled()] ++
[RouterSup || emqx_boot:is_enabled(router)] ++
[BrokerSup || emqx_boot:is_enabled(broker)] ++
[CMSup || emqx_boot:is_enabled(broker)] ++