witness_seed/elixir/lib/witness_seed/supervisor.ex
2025-04-28 16:24:38 -05:00

25 lines
No EOL
548 B
Elixir

defmodule WitnessSeed.Supervisor do
@moduledoc """
Supervisor for the witness cycle processes (nodes) in the swarm.
"""
use Supervisor
def start_link(opts) do
Supervisor.start_link(__MODULE__, opts, name: __MODULE__)
end
@impl true
def init(opts) do
num_nodes = Keyword.get(opts, :num_nodes, 3)
children = Enum.map(1..num_nodes, fn id ->
%{
id: :"Node_#{id}",
start: {WitnessSeed.WitnessCycle, :start_link, [id]}
}
end)
Supervisor.init(children, strategy: :one_for_one)
end
end