From 95f1b9a7f74cb18e9e94654197341ad6a861df55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibaut=20Barr=C3=A8re?= Date: Tue, 24 Dec 2024 11:08:51 +0100 Subject: [PATCH] Shut down the worker app if jobs are not processed anymore --- .../lib/transport_web/plugs/worker_healthcheck.ex | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/apps/transport/lib/transport_web/plugs/worker_healthcheck.ex b/apps/transport/lib/transport_web/plugs/worker_healthcheck.ex index 269386d259..a81964da41 100644 --- a/apps/transport/lib/transport_web/plugs/worker_healthcheck.ex +++ b/apps/transport/lib/transport_web/plugs/worker_healthcheck.ex @@ -12,6 +12,7 @@ defmodule TransportWeb.Plugs.WorkerHealthcheck do if Oban attempted jobs recently. """ import Plug.Conn + require Logger @app_start_waiting_delay {20, :minute} @oban_max_delay_since_last_attempt {60, :minute} @@ -36,6 +37,14 @@ defmodule TransportWeb.Plugs.WorkerHealthcheck do Healthy state?: #{healthy_state?()} """) |> halt() + + # NOTE: Clever Cloud monitoring will better pick stuff back up + # if the app is completely down. + if !healthy_state?() do + Logger.info "Hot-fix: shutting down!!!" + # "Carefully stops the Erlang runtime system." + System.stop() + end else conn end