Source

chut / src / chut_webserver_sup.erl

%%%===================================================================
%%% Supervises a given user and acts as an entry point for the internal
%%% FSM to kill the user.
%%%===================================================================
-module(chut_webserver_sup).
-behaviour(supervisor).

%% supervisor callback
-export([init/1]).
%% API
-export([start_link/1]).

start_link(Port) ->
    supervisor:start_link({local, chut_webserver_sup}, ?MODULE, [Port]).

%%--------------------------------------------------------------------
%% Function: init([UserId, Timeout]) -> [ChildSpec]
%% Description: Creates the children specification for the event
%% manager and the fsm constituting a user. A one for all restart
%% strategy is used because only if the FSM and the event handler can
%% a user work properly.
%%--------------------------------------------------------------------
init([Port]) ->
    {ok, {{one_for_all, 10, 60},
         [{chut_webserver_sup,
           {chut_webserver, start_link, [Port]},
           transient,
           20000,
           worker,
           [chut_webserver]}]}}.