Compare commits
No commits in common. "884796d50c965888f7e7cef505f12dd0978d7c28" and "aeb6db4f7744e6d59961faf6535ce25f399d8aef" have entirely different histories.
884796d50c
...
aeb6db4f77
4 changed files with 16 additions and 33 deletions
|
@ -1,8 +1,4 @@
|
||||||
# 2022-06-13 - v0.4.1
|
# 2022-04-20 - v0.4.0
|
||||||
|
|
||||||
* 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,23 +28,15 @@ 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)
|
||||||
|
|
||||||
case connect(hostname, password) do
|
{:ok, pid} = connect(hostname, password)
|
||||||
{:ok, pid} ->
|
|
||||||
state = %{
|
|
||||||
backend: pid,
|
|
||||||
hostname: hostname,
|
|
||||||
password: password
|
|
||||||
}
|
|
||||||
|
|
||||||
{:ok, state}
|
state = %{
|
||||||
{:error, err} ->
|
backend: pid,
|
||||||
|
hostname: hostname,
|
||||||
|
password: password
|
||||||
|
}
|
||||||
|
|
||||||
# Wait for 10 seconds so that the supervisor does not loop on dead node
|
{:ok, state}
|
||||||
# (and reach the max_restart threshold / stop trying).
|
|
||||||
Process.sleep(10_000)
|
|
||||||
|
|
||||||
{:error, err}
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
|
|
|
@ -12,19 +12,14 @@ 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
|
||||||
case Postgrex.start_link(opts) do
|
{:ok, pid} = Postgrex.start_link(opts)
|
||||||
{:ok, pid} ->
|
|
||||||
state = %{
|
|
||||||
backend: pid,
|
|
||||||
hostname: Keyword.get(opts, :hostname)
|
|
||||||
}
|
|
||||||
|
|
||||||
{:ok, state}
|
state = %{
|
||||||
{:error, err} ->
|
backend: pid,
|
||||||
# Will be catched by the supervisor if anything happen. It should not
|
hostname: Keyword.get(opts, :hostname)
|
||||||
# be triggered even if a PGSQL node down, since Postgrex has its own
|
}
|
||||||
# surpervision tree.
|
|
||||||
{:error, err}
|
{:ok, state}
|
||||||
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.1",
|
version: "0.4.0",
|
||||||
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