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
|
||||
|
||||
* Fix crash on failed SSHEx / Postgrex connection failure.
|
||||
|
||||
# 2022-06-09 - v0.4.0
|
||||
# 2022-04-20 - v0.4.0
|
||||
|
||||
* Add minimal clustering logic.
|
||||
* Fix crash on unavailable HAProxy socket.
|
||||
|
|
|
@ -28,23 +28,15 @@ defmodule HAHandler.DRBD.Watcher do
|
|||
hostname = Keyword.get(opts, :hostname)
|
||||
password = Keyword.get(opts, :password)
|
||||
|
||||
case connect(hostname, password) do
|
||||
{:ok, pid} ->
|
||||
state = %{
|
||||
backend: pid,
|
||||
hostname: hostname,
|
||||
password: password
|
||||
}
|
||||
{:ok, pid} = connect(hostname, password)
|
||||
|
||||
{:ok, state}
|
||||
{:error, err} ->
|
||||
state = %{
|
||||
backend: pid,
|
||||
hostname: hostname,
|
||||
password: password
|
||||
}
|
||||
|
||||
# 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
|
||||
{:ok, state}
|
||||
end
|
||||
|
||||
@impl true
|
||||
|
|
|
@ -12,19 +12,14 @@ defmodule HAHandler.PGSQL.Watcher do
|
|||
# successful.
|
||||
# TODO: set dbconnections backoff and connect hooks
|
||||
# See https://github.com/elixir-ecto/db_connection/blob/master/lib/db_connection.ex#L343
|
||||
case Postgrex.start_link(opts) do
|
||||
{:ok, pid} ->
|
||||
state = %{
|
||||
backend: pid,
|
||||
hostname: Keyword.get(opts, :hostname)
|
||||
}
|
||||
{:ok, pid} = Postgrex.start_link(opts)
|
||||
|
||||
{:ok, state}
|
||||
{:error, err} ->
|
||||
# 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.
|
||||
{:error, err}
|
||||
state = %{
|
||||
backend: pid,
|
||||
hostname: Keyword.get(opts, :hostname)
|
||||
}
|
||||
|
||||
{:ok, state}
|
||||
end
|
||||
|
||||
@impl true
|
||||
|
|
2
mix.exs
2
mix.exs
|
@ -4,7 +4,7 @@ defmodule HAHandler.MixProject do
|
|||
def project do
|
||||
[
|
||||
app: :ha_handler,
|
||||
version: "0.4.1",
|
||||
version: "0.4.0",
|
||||
elixir: "~> 1.12",
|
||||
start_permanent: Mix.env() == :prod,
|
||||
deps: deps(),
|
||||
|
|
Loading…
Reference in a new issue