Compare commits
2 commits
aeb6db4f77
...
884796d50c
Author | SHA1 | Date | |
---|---|---|---|
|
884796d50c | ||
|
4a2b6a4948 |
4 changed files with 33 additions and 16 deletions
|
@ -1,4 +1,8 @@
|
||||||
# 2022-04-20 - v0.4.0
|
# 2022-06-13 - v0.4.1
|
||||||
|
|
||||||
|
* Fix crash on failed SSHEx / Postgrex connection failure.
|
||||||
|
|
||||||
|
# 2022-06-09 - v0.4.0
|
||||||
|
|
||||||
* Add minimal clustering logic.
|
* Add minimal clustering logic.
|
||||||
* Fix crash on unavailable HAProxy socket.
|
* Fix crash on unavailable HAProxy socket.
|
||||||
|
|
|
@ -28,15 +28,23 @@ defmodule HAHandler.DRBD.Watcher do
|
||||||
hostname = Keyword.get(opts, :hostname)
|
hostname = Keyword.get(opts, :hostname)
|
||||||
password = Keyword.get(opts, :password)
|
password = Keyword.get(opts, :password)
|
||||||
|
|
||||||
{:ok, pid} = connect(hostname, password)
|
case connect(hostname, password) do
|
||||||
|
{:ok, pid} ->
|
||||||
|
state = %{
|
||||||
|
backend: pid,
|
||||||
|
hostname: hostname,
|
||||||
|
password: password
|
||||||
|
}
|
||||||
|
|
||||||
state = %{
|
{:ok, state}
|
||||||
backend: pid,
|
{:error, err} ->
|
||||||
hostname: hostname,
|
|
||||||
password: password
|
|
||||||
}
|
|
||||||
|
|
||||||
{:ok, state}
|
# Wait for 10 seconds so that the supervisor does not loop on dead node
|
||||||
|
# (and reach the max_restart threshold / stop trying).
|
||||||
|
Process.sleep(10_000)
|
||||||
|
|
||||||
|
{:error, err}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
|
|
|
@ -12,14 +12,19 @@ defmodule HAHandler.PGSQL.Watcher do
|
||||||
# successful.
|
# successful.
|
||||||
# TODO: set dbconnections backoff and connect hooks
|
# TODO: set dbconnections backoff and connect hooks
|
||||||
# See https://github.com/elixir-ecto/db_connection/blob/master/lib/db_connection.ex#L343
|
# See https://github.com/elixir-ecto/db_connection/blob/master/lib/db_connection.ex#L343
|
||||||
{:ok, pid} = Postgrex.start_link(opts)
|
case Postgrex.start_link(opts) do
|
||||||
|
{:ok, pid} ->
|
||||||
|
state = %{
|
||||||
|
backend: pid,
|
||||||
|
hostname: Keyword.get(opts, :hostname)
|
||||||
|
}
|
||||||
|
|
||||||
state = %{
|
{:ok, state}
|
||||||
backend: pid,
|
{:error, err} ->
|
||||||
hostname: Keyword.get(opts, :hostname)
|
# Will be catched by the supervisor if anything happen. It should not
|
||||||
}
|
# be triggered even if a PGSQL node down, since Postgrex has its own
|
||||||
|
# surpervision tree.
|
||||||
{:ok, state}
|
{:error, err}
|
||||||
end
|
end
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
|
|
2
mix.exs
2
mix.exs
|
@ -4,7 +4,7 @@ defmodule HAHandler.MixProject do
|
||||||
def project do
|
def project do
|
||||||
[
|
[
|
||||||
app: :ha_handler,
|
app: :ha_handler,
|
||||||
version: "0.4.0",
|
version: "0.4.1",
|
||||||
elixir: "~> 1.12",
|
elixir: "~> 1.12",
|
||||||
start_permanent: Mix.env() == :prod,
|
start_permanent: Mix.env() == :prod,
|
||||||
deps: deps(),
|
deps: deps(),
|
||||||
|
|
Loading…
Reference in a new issue