diff --git a/lib/aprsme_web/plugs/health_check.ex b/lib/aprsme_web/plugs/health_check.ex index ec8dfec..bf3e8c6 100644 --- a/lib/aprsme_web/plugs/health_check.ex +++ b/lib/aprsme_web/plugs/health_check.ex @@ -47,7 +47,7 @@ defmodule AprsmeWeb.Plugs.HealthCheck do health_status == :draining -> {:error, "Application is draining connections"} - Aprsme.ShutdownHandler.shutting_down?() -> + shutting_down?() -> {:error, "Application is shutting down"} true -> @@ -105,4 +105,26 @@ defmodule AprsmeWeb.Plugs.HealthCheck do rescue _ -> {:error, "PubSub check failed"} end + + defp shutting_down? do + # Check if ShutdownHandler process exists and is shutting down + case Process.whereis(Aprsme.ShutdownHandler) do + nil -> + # Process doesn't exist, not shutting down + false + + pid when is_pid(pid) -> + # Process exists, check if alive and call it + if Process.alive?(pid) do + try do + GenServer.call(pid, :shutting_down?, 5000) + catch + :exit, _ -> false + _, _ -> false + end + else + false + end + end + end end