This repository was archived by the owner on Dec 2, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathapplication.ex
More file actions
51 lines (47 loc) · 1.91 KB
/
application.ex
File metadata and controls
51 lines (47 loc) · 1.91 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
defmodule ExARIExample.Application do
@moduledoc """
Documentation for ExAriExample.
"""
use Application
alias ARI.{ChannelRegistrar, Configurator, HTTP, Stasis}
alias ExARIExample.Router
def start(_, _) do
un = System.get_env("ASTERISK_USERNAME")
pw = System.get_env("ASTERISK_PASSWORD")
ws_host = System.get_env("ASTERISK_WS_HOST")
rest_host = System.get_env("ASTERISK_REST_HOST")
rest_port = System.get_env("ASTERISK_REST_PORT") |> String.to_integer()
name = System.get_env("ASTERISK_NAME")
transport = System.get_env("ASTERISK_TRANSPORT")
context = System.get_env("ASTERISK_CONTEXT")
channel_supervisor = ExARIExample.ChannelSupervisor
config_module = Application.get_env(:ex_ari_example, :config_module)
client_config = %{name: "ex_ari", module: ExARIExample.Client}
router_config = Application.get_env(:ex_ari_example, :router)
children = [
ChannelRegistrar,
{DynamicSupervisor, strategy: :one_for_one, name: channel_supervisor},
{HTTP.Asterisk, [rest_host, rest_port, un, pw]},
{HTTP.Channels, [rest_host, rest_port, un, pw]},
{HTTP.Playbacks, [rest_host, rest_port, un, pw]},
{HTTP.Recordings, [rest_host, rest_port, un, pw]},
{HTTP.Events, [rest_host, rest_port, un, pw]},
{Stasis, [channel_supervisor, client_config, ws_host, un, pw]},
{Stasis, [channel_supervisor, router_config, ws_host, un, pw]},
{Configurator, [name, transport, context, config_module]},
{Plug.Cowboy, scheme: :http, plug: Router, options: [port: 4001, dispatch: dispatch()]}
]
opts = [strategy: :one_for_one, name: ExARIExample.Supervisor]
Supervisor.start_link(children, opts)
end
defp dispatch do
[
{:_,
[
{"/sound/[...]", :cowboy_static,
{:dir, Path.join(:code.priv_dir(:ex_ari_example), "sounds"),
[{:mimetypes, {<<"audio">>, <<"basic">>, []}}]}}
]}
]
end
end