forked from OpenTelecom/kazoo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ecallmgr_app.erl
89 lines (76 loc) · 2.79 KB
/
ecallmgr_app.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
%%%-----------------------------------------------------------------------------
%%% @copyright (C) 2012-2018, 2600Hz
%%% @doc
%%% @end
%%%-----------------------------------------------------------------------------
-module(ecallmgr_app).
-behaviour(application).
-include("ecallmgr.hrl").
-export([start/2
,request/1
]).
-export([stop/1]).
-export([freeswitch_node_modules/0]).
%% Application callbacks
%% @doc Implement the application start behaviour.
-spec start(application:start_type(), any()) -> kz_types:startapp_ret().
start(_StartType, _StartArgs) ->
_ = declare_exchanges(),
_ = node_bindings(),
_ = freeswitch_nodesup_bind(),
ecallmgr_sup:start_link().
-spec request(kz_nodes:request_acc()) -> kz_nodes:request_acc().
request(Acc) ->
Servers = [{kz_term:to_binary(Server)
,kz_json:from_list(
[{<<"Startup">>, Started}
,{<<"Interfaces">>, ecallmgr_fs_node:interfaces(Server)}
])
}
|| {Server, Started} <- ecallmgr_fs_nodes:connected('true')
],
[{'media_servers', Servers}
,{'channels', ecallmgr_fs_channels:count()}
,{'conferences', ecallmgr_fs_conferences:count()}
,{'registrations', ecallmgr_registrar:count()}
| Acc
].
%% @doc Implement the application stop behaviour.
-spec stop(any()) -> any().
stop(_State) ->
_ = freeswitch_nodesup_unbind(),
_ = kz_nodes_bindings:unbind('ecallmgr', ?MODULE),
'ok'.
-spec declare_exchanges() -> 'ok'.
declare_exchanges() ->
_ = kapi_authn:declare_exchanges(),
_ = kapi_authz:declare_exchanges(),
_ = kapi_call:declare_exchanges(),
_ = kapi_conference:declare_exchanges(),
_ = kapi_dialplan:declare_exchanges(),
_ = kapi_media:declare_exchanges(),
_ = kapi_notifications:declare_exchanges(),
_ = kapi_rate:declare_exchanges(),
_ = kapi_registration:declare_exchanges(),
_ = kapi_resource:declare_exchanges(),
_ = kapi_route:declare_exchanges(),
_ = kapi_sysconf:declare_exchanges(),
_ = kapi_sms:declare_exchanges(),
_ = kapi_switch:declare_exchanges(),
_ = kapi_presence:declare_exchanges(),
kapi_self:declare_exchanges().
-spec node_bindings() -> 'ok'.
node_bindings() ->
_ = kz_nodes_bindings:bind('ecallmgr', ?MODULE),
'ok'.
-spec freeswitch_nodesup_bind() -> 'ok'.
freeswitch_nodesup_bind() ->
_ = kazoo_bindings:bind(<<"freeswitch.node.modules">>, ?MODULE, 'freeswitch_node_modules'),
'ok'.
-spec freeswitch_nodesup_unbind() -> 'ok'.
freeswitch_nodesup_unbind() ->
_ = kazoo_bindings:unbind(<<"freeswitch.node.modules">>, ?MODULE, 'freeswitch_node_modules'),
'ok'.
-spec freeswitch_node_modules() -> kz_term:ne_binaries().
freeswitch_node_modules() ->
application:get_env(?APP, 'node_modules', ?NODE_MODULES).