Add src/hk_frontend_sup.erl
Browse files- src/hk_frontend_sup.erl +30 -0
src/hk_frontend_sup.erl
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
%%%-------------------------------------------------------------------
|
| 2 |
+
%%% @doc Supervises the frontend plane's server-side state (the
|
| 3 |
+
%%% connected-client registry). The static assets and the actual
|
| 4 |
+
%%% WebSocket/HTTP endpoints are served by Cowboy under `hk_api_sup'
|
| 5 |
+
%%% (Cowboy owns its own listener/acceptor supervision tree, which
|
| 6 |
+
%%% duplicating here would only fight); this supervisor's job is the
|
| 7 |
+
%%% frontend-specific process boundary the spec calls for, distinct
|
| 8 |
+
%%% from request handling itself.
|
| 9 |
+
%%% @end
|
| 10 |
+
%%%-------------------------------------------------------------------
|
| 11 |
+
-module(hk_frontend_sup).
|
| 12 |
+
-behaviour(supervisor).
|
| 13 |
+
|
| 14 |
+
-export([start_link/0, init/1]).
|
| 15 |
+
|
| 16 |
+
start_link() ->
|
| 17 |
+
hk_sup_util:start_link_retry(
|
| 18 |
+
fun() -> supervisor:start_link({local, ?MODULE}, ?MODULE, []) end).
|
| 19 |
+
|
| 20 |
+
init([]) ->
|
| 21 |
+
SupFlags = #{strategy => one_for_one, intensity => 10, period => 10},
|
| 22 |
+
Children = [
|
| 23 |
+
#{id => hk_frontend_client_registry,
|
| 24 |
+
start => {hk_frontend_client_registry, start_link, []},
|
| 25 |
+
restart => permanent,
|
| 26 |
+
shutdown => 5000,
|
| 27 |
+
type => worker,
|
| 28 |
+
modules => [hk_frontend_client_registry]}
|
| 29 |
+
],
|
| 30 |
+
{ok, {SupFlags, Children}}.
|