diff options
Diffstat (limited to 'lib/mediasync/application.ex')
-rw-r--r-- | lib/mediasync/application.ex | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/lib/mediasync/application.ex b/lib/mediasync/application.ex new file mode 100644 index 0000000..1e8f6d4 --- /dev/null +++ b/lib/mediasync/application.ex @@ -0,0 +1,35 @@ +defmodule Mediasync.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 + children = [ + # Starts a worker by calling: Mediasync.Worker.start_link(arg) + # {Mediasync.Worker, arg} + {Bandit, + plug: Mediasync.Router, + scheme: :http, + ip: {127, 0, 0, 1}, + port: Application.get_env(:mediasync, :port)}, + {DynamicSupervisor, + max_children: Application.get_env(:mediasync, :max_rooms), + max_restarts: 0, + strategy: :one_for_one, + name: Mediasync.RoomSupervisor}, + {Registry, keys: :unique, name: Mediasync.RoomRegistry}, + {Registry, keys: :unique, name: Mediasync.RoomConnectionRegistry}, + {Registry, keys: :duplicate, name: Mediasync.RoomSubscriptionRegistry} + ] + + System.no_halt(true) + + # See https://hexdocs.pm/elixir/Supervisor.html + # for other strategies and supported options + opts = [strategy: :one_for_one, name: Mediasync.Supervisor] + Supervisor.start_link(children, opts) + end +end |