Source

chut / src / chut_sup.erl

%%%===================================================================
%%% Top supervisor for the chut application and its web server.
%%%===================================================================
-module(chut_sup).
-behaviour(supervisor).

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

start_link(Port) ->
    supervisor:start_link({local, ?MODULE}, ?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]) ->
    ChutSpec = {chut_user_supersup,
                {chut_user_supersup, start_link, []},
                permanent,
                infinity,
                supervisor,
                [chut_user_supersup]},
    ServerSpec = {chut_webserver_sup,
                  {chut_webserver_sup, start_link, [Port]},
                  permanent,
                  infinity,
                  supervisor,
                  [chut_webserver_sup]},
    {ok, {{rest_for_one, 10, 60}, [ChutSpec, ServerSpec]}}.