snapkitty
developer-tools
c++
File size: 1,620 Bytes
0196580
 
 
43d2fa5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
% SPDX-License-Identifier: LicenseRef-Sovereign-Leviathan-SL-AGPL3-001
% Licensing: see LICENSE in the repository root.

%%%-------------------------------------------------------------------
%%% @doc HK-BROWSER plane supervisor: the session registry and the
%%% session pool are two independent children (not one
%%% `simple_one_for_one' supervisor mixing a singleton with dynamic
%%% children, which OTP does not allow) so that neither can take the
%%% other down. `one_for_one': the registry restarting (it holds no
%%% durable state other than in-memory pid mappings, which are
%%% rebuilt as sessions re-register) does not restart live sessions,
%%% and a session-pool restart storm does not restart the registry.
%%% @end
%%%-------------------------------------------------------------------
-module(hk_browser_sup).
-behaviour(supervisor).

-export([start_link/0, init/1]).

start_link() ->
    hk_sup_util:start_link_retry(
        fun() -> supervisor:start_link({local, ?MODULE}, ?MODULE, []) end).

init([]) ->
    SupFlags = #{strategy => one_for_one, intensity => 10, period => 10},
    Children = [
        #{id => hk_browser_registry,
          start => {hk_browser_registry, start_link, []},
          restart => permanent,
          shutdown => 5000,
          type => worker,
          modules => [hk_browser_registry]},
        #{id => hk_browser_session_sup,
          start => {hk_browser_session_sup, start_link, []},
          restart => permanent,
          shutdown => infinity,
          type => supervisor,
          modules => [hk_browser_session_sup]}
    ],
    {ok, {SupFlags, Children}}.