23 lines
506 B
Elixir
23 lines
506 B
Elixir
defmodule HAHandler.PGSQL.Supervisor do
|
|
use Supervisor
|
|
|
|
alias HAHandler.PGSQL.Watcher, as: PGSQLWatcher
|
|
|
|
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: {PGSQLWatcher, :start_link, [conf]}
|
|
}
|
|
end)
|
|
|
|
opts = [strategy: :one_for_one]
|
|
Supervisor.init(children, opts)
|
|
end
|
|
end
|