Skip to content
This repository
Fetching contributors…

Cannot retrieve contributors at this time

file 60 lines (48 sloc) 2.136 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
%%%----------------------------------------------------------------------
%%% File : gproc_sup.erl
%%% Purpose : GPROC top-level supervisor
%%%----------------------------------------------------------------------

-module(gproc_sup).

-behaviour(supervisor).

%% External exports
-export([start_link/1]).

%% supervisor callbacks
-export([init/1]).

%%%----------------------------------------------------------------------
%%% API
%%%----------------------------------------------------------------------
start_link(Args) ->
    supervisor:start_link({local, ?MODULE}, ?MODULE, Args).

%%%----------------------------------------------------------------------
%%% Callback functions from supervisor
%%%----------------------------------------------------------------------

%%----------------------------------------------------------------------
%% Func: init/1
%% Returns: {ok, {SupFlags, [ChildSpec]}} |
%% ignore |
%% {error, Reason}
%%----------------------------------------------------------------------
%% @spec(_Args::term()) -> {ok, {supervisor_flags(), child_spec_list()}}
%% @doc The main GPROC supervisor.

init(_Args) ->
    %% Hint:
    %% Child_spec = [Name, {M, F, A},
    %% Restart, Shutdown_time, Type, Modules_used]

    GProc =
        {gproc, {gproc, start_link, []},
         permanent, 2000, worker, [gproc]},

    Dist = case application:get_env(gproc_dist) of
               undefined -> [];
               {ok, false} -> [];
               {ok, Env} ->
                   [{gproc_dist, {gproc_dist, start_link, [Env]},
                     permanent, 2000, worker, [gproc_dist]}]
           end,
    Mon = {gproc_monitor, {gproc_monitor, start_link, []},
permanent, 2000, worker, [gproc_monitor]},
    BCast = {gproc_bcast, {gproc_bcast, start_link, []},
permanent, 2000, worker, [gproc_bcast]},
    {ok,{{one_for_one, 15, 60}, [GProc| Dist] ++ [Mon, BCast]}}.


%%%----------------------------------------------------------------------
%%% Internal functions
%%%----------------------------------------------------------------------
Something went wrong with that request. Please try again.