Add src/hk_browser_sup.erl
Browse files- src/hk_browser_sup.erl +37 -0
src/hk_browser_sup.erl
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
%%%-------------------------------------------------------------------
|
| 2 |
+
%%% @doc HK-BROWSER plane supervisor: the session registry and the
|
| 3 |
+
%%% session pool are two independent children (not one
|
| 4 |
+
%%% `simple_one_for_one' supervisor mixing a singleton with dynamic
|
| 5 |
+
%%% children, which OTP does not allow) so that neither can take the
|
| 6 |
+
%%% other down. `one_for_one': the registry restarting (it holds no
|
| 7 |
+
%%% durable state other than in-memory pid mappings, which are
|
| 8 |
+
%%% rebuilt as sessions re-register) does not restart live sessions,
|
| 9 |
+
%%% and a session-pool restart storm does not restart the registry.
|
| 10 |
+
%%% @end
|
| 11 |
+
%%%-------------------------------------------------------------------
|
| 12 |
+
-module(hk_browser_sup).
|
| 13 |
+
-behaviour(supervisor).
|
| 14 |
+
|
| 15 |
+
-export([start_link/0, init/1]).
|
| 16 |
+
|
| 17 |
+
start_link() ->
|
| 18 |
+
hk_sup_util:start_link_retry(
|
| 19 |
+
fun() -> supervisor:start_link({local, ?MODULE}, ?MODULE, []) end).
|
| 20 |
+
|
| 21 |
+
init([]) ->
|
| 22 |
+
SupFlags = #{strategy => one_for_one, intensity => 10, period => 10},
|
| 23 |
+
Children = [
|
| 24 |
+
#{id => hk_browser_registry,
|
| 25 |
+
start => {hk_browser_registry, start_link, []},
|
| 26 |
+
restart => permanent,
|
| 27 |
+
shutdown => 5000,
|
| 28 |
+
type => worker,
|
| 29 |
+
modules => [hk_browser_registry]},
|
| 30 |
+
#{id => hk_browser_session_sup,
|
| 31 |
+
start => {hk_browser_session_sup, start_link, []},
|
| 32 |
+
restart => permanent,
|
| 33 |
+
shutdown => infinity,
|
| 34 |
+
type => supervisor,
|
| 35 |
+
modules => [hk_browser_session_sup]}
|
| 36 |
+
],
|
| 37 |
+
{ok, {SupFlags, Children}}.
|