study-system/server/src/session_sup.erl

26 lines
646 B
Erlang

% Copyright (c) Camden Dixie O'Brien
% SPDX-License-Identifier: AGPL-3.0-only
-module(session_sup).
-behaviour(supervisor).
-export([start_link/0, init/1, start_session/1]).
start_link() ->
supervisor:start_link({local, ?MODULE}, ?MODULE, []).
init([]) ->
SupFlags = #{strategy => simple_one_for_one,
intensity => 10,
period => 1},
ChildSpec = #{id => session_server,
start => {session_server, start_link, []},
restart => temporary,
shutdown => 5000,
type => worker,
modules => [session_server]},
{ok, {SupFlags, [ChildSpec]}}.
start_session(Socket) ->
supervisor:start_child(?MODULE, [Socket]).