/
monitor.erl
50 lines (41 loc) · 1.13 KB
/
monitor.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
%%% @author Karl Anderson <karl@2600hz.org>
%%% @copyright (C) 2010, Karl Anderson
%%% @doc
%%% Service/Server Monitoring
%%% @end
%%% Created : 11 Nov 2010 by Karl Anderson <karl@2600hz.org>
-module(monitor).
-author('Karl Anderson <karl@2600hz.com>').
-export([start/0, start_link/0, start_link/1, stop/0, set_amqp_host/1]).
%% @spec start_link() -> {ok,Pid::pid()}
%% @doc Starts the monitor for inclusion in a supervisor tree
start_link() ->
start_deps(),
monitor_sup:start_link().
start_link(AHost) ->
start_deps(),
monitor_sup:start_link(AHost).
%% @spec start() -> ok
%% @doc Start the monitor server.
start() ->
application:start(monitor).
start_deps() ->
monitor_deps:ensure(),
ensure_started(sasl),
ensure_started(crypto),
ensure_started(whistle_amqp),
ensure_started(couchbeam),
ensure_started(whistle_couch).
%% @spec stop() -> ok
%% @doc Stop the monitor server.
stop() ->
application:stop(monitor).
ensure_started(App) ->
case application:start(App) of
ok ->
ok;
{error, {already_started, App}} ->
ok
end.
set_amqp_host(_) ->
ok.