fp-lab4/lib/exdns/application.ex
2026-01-13 18:26:26 +03:00

30 lines
980 B
Elixir

defmodule Exdns.Application do
# See https://hexdocs.pm/elixir/Application.html
# for more information on OTP Applications
@moduledoc false
use Application
@impl true
def start(_type, _args) do
token = Application.fetch_env!(:exdns, :auth_token)
http_port = Application.fetch_env!(:exdns, :http_port)
dns_port = Application.fetch_env!(:exdns, :dns_port)
tcp_port = Application.fetch_env!(:exdns, :dns_tcp_port)
children = [
# Starts a worker by calling: Exdns.Worker.start_link(arg)
# {Exdns.Worker, arg}
{Exdns.ZoneServer, []},
{Exdns.UdpListener, port: dns_port},
{Exdns.TcpListener, port: tcp_port},
{Bandit, plug: {Exdns.HttpRouter, auth_token: token}, scheme: :http, port: http_port}
]
# See https://hexdocs.pm/elixir/Supervisor.html
# for other strategies and supported options
opts = [strategy: :one_for_one, name: Exdns.Supervisor]
Supervisor.start_link(children, opts)
end
end