control: do not crash on unavaible HAproxy socket

This commit is contained in:
Timothée Floure 2022-05-22 13:03:58 +02:00
parent 9915bff2a7
commit 77ebea3746
Signed by: tfloure
GPG Key ID: 4502C902C00A1E12
1 changed files with 7 additions and 2 deletions

View File

@ -173,8 +173,13 @@ defmodule HAHandler.Control do
def handle_info(:sync, state) do
Logger.debug("Executing control logic.")
process_pgsql()
process_drbd()
case HAProxy.get_stats() do
%{} ->
process_pgsql()
process_drbd()
{:error, err} ->
Logger.error("Unable to fetch HAProxy state (#{inspect(err)}( - skipping control loop.")
end
# Schedule next round.
Process.send_after(self(), :sync, @refresh)