-
Notifications
You must be signed in to change notification settings - Fork 461
/
monitor_sup.erl
47 lines (37 loc) · 1.61 KB
/
monitor_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
%%%-------------------------------------------------------------------
%%% @author Karl Anderson <karl@2600hz.com>
%%% @copyright (C) 2010, Karl Anderson
%%% @doc
%%% Responsible for supervising the whistle monitoring application
%%% @end
%%% Created : 11 Nov 2010 by Karl Anderson <karl@2600hz.com>
%%%-------------------------------------------------------------------
-module(monitor_sup).
-behaviour(supervisor).
-include("monitor_amqp.hrl").
%% API
-export([start_link/1, start_link/0]).
%% Supervisor callbacks
-export([init/1]).
%% ===================================================================
%% API functions
%% ===================================================================
start_link() ->
supervisor:start_link({local, ?MODULE}, ?MODULE, [?AMQP_HOST]).
start_link(AHost) ->
supervisor:start_link({local, ?MODULE}, ?MODULE, [AHost]).
%% ===================================================================
%% Supervisor callbacks
%% ===================================================================
init([]) ->
init([""]);
init([AHost]) ->
MonitorMaster = {monitor_master, {monitor_master, start_link, [AHost]},
permanent, 2000, worker, [monitor_master]},
AgentSup = {monitor_agent_sup, {monitor_agent_sup, start_link, [AHost]},
permanent, 2000, supervisor, [monitor_agent_sup]},
JobSup = {monitor_job_sup, {monitor_job_sup, start_link, []},
permanent, 2000, supervisor, [monitor_job_sup]},
Children = [MonitorMaster, AgentSup, JobSup],
Restart = {one_for_one, 5, 10},
{ok, {Restart, Children}}.