2022-02-25 13:39:58 +01:00
|
|
|
defmodule HAHandler.DRBD.Supervisor do
|
|
|
|
use Supervisor
|
|
|
|
|
|
|
|
alias HAHandler.DRBD.Watcher, as: DRBDWatcher
|
|
|
|
|
|
|
|
def start_link(opts) do
|
|
|
|
Supervisor.start_link(__MODULE__, opts, name: __MODULE__)
|
|
|
|
end
|
|
|
|
|
|
|
|
@impl true
|
|
|
|
def init(instances) do
|
|
|
|
children =
|
|
|
|
Enum.map(instances, fn conf ->
|
|
|
|
%{
|
|
|
|
id: Keyword.get(conf, :hostname),
|
|
|
|
start: {DRBDWatcher, :start_link, [conf]}
|
|
|
|
}
|
|
|
|
end)
|
|
|
|
|
2022-07-04 12:27:44 +02:00
|
|
|
opts = [
|
|
|
|
strategy: :one_for_one
|
|
|
|
]
|
2022-02-25 13:39:58 +01:00
|
|
|
Supervisor.init(children, opts)
|
|
|
|
end
|
|
|
|
end
|