1
0
mirror of https://github.com/algora-io/tv.git synced 2025-03-17 20:17:45 +02:00
algora-tv/lib/algora/application.ex
2024-09-01 02:15:24 +03:00

80 lines
2.4 KiB
Elixir

defmodule Algora.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
topologies = Application.get_env(:libcluster, :topologies) || []
tcp_server_options = %Membrane.RTMP.Source.TcpServer{
port: Algora.config([:rtmp_port]),
listen_options: [
:binary,
packet: :raw,
active: false,
ip: {0, 0, 0, 0}
],
socket_handler: fn socket ->
{:ok, _sup, pid} =
Membrane.Pipeline.start_link(Algora.Pipeline, socket: socket)
{:ok, pid}
end
}
children = [
Algora.Env,
{Cluster.Supervisor, [topologies, [name: Algora.ClusterSupervisor]]},
{Task.Supervisor, name: Algora.TaskSupervisor},
# Start the RPC server
{Fly.RPC, []},
# Start the Ecto repository
Algora.Repo.Local,
# Start the supervisor for LSN tracking
{Fly.Postgres.LSN.Supervisor, repo: Algora.Repo.Local},
# Start the Oban system
{Oban, Application.fetch_env!(:algora, Oban)},
# Start the Telemetry supervisor
AlgoraWeb.Telemetry,
# Start the PubSub system
{Phoenix.PubSub, name: Algora.PubSub},
# Start presence
AlgoraWeb.Presence,
{Finch, name: Algora.Finch},
# Clustering setup
{DNSCluster, query: Application.get_env(:algora, :dns_cluster_query) || :ignore},
# Start the Endpoints (http/https)
AlgoraWeb.Endpoint,
AlgoraWeb.Embed.Endpoint,
# Start the RTMP server
%{
id: Membrane.RTMP.Source.TcpServer,
start: {Membrane.RTMP.Source.TcpServer, :start_link, [tcp_server_options]}
},
Algora.Stargazer,
Algora.Terminate,
ExMarcel.TableWrapper,
Algora.Youtube.Chat.Supervisor
# Start a worker by calling: Algora.Worker.start_link(arg)
# {Algora.Worker, arg}
]
# See https://hexdocs.pm/elixir/Supervisor.html
# for other strategies and supported options
opts = [strategy: :one_for_one, name: Algora.Supervisor]
Supervisor.start_link(children, opts)
end
# Tell Phoenix to update the endpoint configuration
# whenever the application is updated.
@impl true
def config_change(changed, _new, removed) do
AlgoraWeb.Endpoint.config_change(changed, removed)
AlgoraWeb.Embed.Endpoint.config_change(changed, removed)
:ok
end
end