From 77ebea3746a0cdb47e49b4ffe912449f7631381f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Floure?= Date: Sun, 22 May 2022 13:03:58 +0200 Subject: [PATCH] control: do not crash on unavaible HAproxy socket --- lib/ha_handler/control.ex | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/ha_handler/control.ex b/lib/ha_handler/control.ex index 9ee6985..2d96f24 100644 --- a/lib/ha_handler/control.ex +++ b/lib/ha_handler/control.ex @@ -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)