Skip to content

Commit 50f7871

Browse files
authored
[Broadcaster] Start dist config before starting Forwarder (#75)
1 parent b22cf56 commit 50f7871

File tree

2 files changed

+20
-13
lines changed

2 files changed

+20
-13
lines changed

broadcaster/lib/broadcaster/application.ex

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,31 @@ defmodule Broadcaster.Application do
1212

1313
@impl true
1414
def start(_type, _args) do
15+
dist_config =
16+
case Application.fetch_env!(:broadcaster, :dist_config) do
17+
nil ->
18+
[]
19+
20+
config ->
21+
[{Cluster.Supervisor, [[cluster: config], [name: Broadcaster.ClusterSupervisor]]}]
22+
end
23+
24+
# Start dist_config before starting Forwarder,
25+
# as Forwarder asks other nodes for their inputs.
1526
children =
1627
[
1728
BroadcasterWeb.Telemetry,
1829
{Phoenix.PubSub, name: Broadcaster.PubSub},
1930
BroadcasterWeb.Endpoint,
20-
BroadcasterWeb.Presence,
21-
Broadcaster.PeerSupervisor,
22-
Broadcaster.Forwarder,
23-
Broadcaster.ChatHistory,
24-
{Registry, name: Broadcaster.ChatNicknamesRegistry, keys: :unique}
31+
BroadcasterWeb.Presence
2532
] ++
26-
case Application.fetch_env!(:broadcaster, :dist_config) do
27-
nil ->
28-
[]
29-
30-
config ->
31-
[{Cluster.Supervisor, [[cluster: config], [name: Broadcaster.ClusterSupervisor]]}]
32-
end
33+
dist_config ++
34+
[
35+
Broadcaster.PeerSupervisor,
36+
Broadcaster.Forwarder,
37+
Broadcaster.ChatHistory,
38+
{Registry, name: Broadcaster.ChatNicknamesRegistry, keys: :unique}
39+
]
3340

3441
# See https://hexdocs.pm/elixir/Supervisor.html
3542
# for other strategies and supported options

broadcaster/mix.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ defmodule Broadcaster.MixProject do
44
def project do
55
[
66
app: :broadcaster,
7-
version: "0.8.0",
7+
version: "0.8.1",
88
elixir: "~> 1.14",
99
elixirc_paths: elixirc_paths(Mix.env()),
1010
start_permanent: Mix.env() == :prod,

0 commit comments

Comments
 (0)