forked from OpenTelecom/kazoo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathskel_sup.erl
54 lines (43 loc) · 1.84 KB
/
skel_sup.erl
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
%%%-----------------------------------------------------------------------------
%%% @copyright (C) 2010-2018, 2600Hz
%%% @doc
%%% @end
%%%-----------------------------------------------------------------------------
-module(skel_sup).
-behaviour(supervisor).
-export([start_link/0]).
-export([init/1]).
-include("skel.hrl").
-define(SERVER, ?MODULE).
%% Helper macro for declaring children of supervisor
-define(CHILDREN, [?CACHE(?CACHE_NAME)
,?WORKER('skel_listener')
]).
%%==============================================================================
%% API functions
%%==============================================================================
%%------------------------------------------------------------------------------
%% @doc Starts the supervisor.
%% @end
%%------------------------------------------------------------------------------
-spec start_link() -> kz_types:startlink_ret().
start_link() ->
supervisor:start_link({'local', ?SERVER}, ?MODULE, []).
%%==============================================================================
%% Supervisor callbacks
%%==============================================================================
%%------------------------------------------------------------------------------
%% @doc Whenever a supervisor is started using `supervisor:start_link/[2,3]',
%% this function is called by the new process to find out about
%% restart strategy, maximum restart frequency and child
%% specifications.
%% @end
%%------------------------------------------------------------------------------
-spec init(any()) -> kz_types:sup_init_ret().
init([]) ->
kz_util:set_startup(),
RestartStrategy = 'one_for_one',
MaxRestarts = 5,
MaxSecondsBetweenRestarts = 10,
SupFlags = {RestartStrategy, MaxRestarts, MaxSecondsBetweenRestarts},
{'ok', {SupFlags, ?CHILDREN}}.