Include compact worker in readiness
This commit is contained in:
parent
94d4e6dae1
commit
a65d7d126f
|
|
@ -7,10 +7,24 @@ defmodule WhoNeedHelpWeb.HealthController do
|
||||||
if WhoNeedHelpWeb.DrainState.draining?() do
|
if WhoNeedHelpWeb.DrainState.draining?() do
|
||||||
conn |> put_status(:service_unavailable) |> json(%{status: "draining"})
|
conn |> put_status(:service_unavailable) |> json(%{status: "draining"})
|
||||||
else
|
else
|
||||||
case Ecto.Adapters.SQL.query(WhoNeedHelp.Repo, "SELECT 1", []) do
|
database_ready? =
|
||||||
{:ok, _} -> json(conn, %{status: "ready"})
|
match?({:ok, _}, Ecto.Adapters.SQL.query(WhoNeedHelp.Repo, "SELECT 1", []))
|
||||||
{:error, _} -> conn |> put_status(:service_unavailable) |> json(%{status: "not_ready"})
|
|
||||||
|
if ready?(
|
||||||
|
Application.fetch_env!(:who_need_help, :app_role),
|
||||||
|
database_ready?,
|
||||||
|
Oban.whereis(Oban)
|
||||||
|
) do
|
||||||
|
json(conn, %{status: "ready"})
|
||||||
|
else
|
||||||
|
conn |> put_status(:service_unavailable) |> json(%{status: "not_ready"})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@doc false
|
||||||
|
def ready?(:combined, database_ready?, oban_pid),
|
||||||
|
do: database_ready? and is_pid(oban_pid)
|
||||||
|
|
||||||
|
def ready?(_role, database_ready?, _oban_pid), do: database_ready?
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -165,6 +165,15 @@ defmodule WhoNeedHelpWeb.PageControllerTest do
|
||||||
|> json_response(200)
|
|> json_response(200)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "combined readiness also requires its in-process Oban worker" do
|
||||||
|
assert WhoNeedHelpWeb.HealthController.ready?(:combined, true, self())
|
||||||
|
refute WhoNeedHelpWeb.HealthController.ready?(:combined, true, nil)
|
||||||
|
refute WhoNeedHelpWeb.HealthController.ready?(:combined, false, self())
|
||||||
|
|
||||||
|
assert WhoNeedHelpWeb.HealthController.ready?(:web, true, nil)
|
||||||
|
refute WhoNeedHelpWeb.HealthController.ready?(:web, false, self())
|
||||||
|
end
|
||||||
|
|
||||||
test "GET /safety selects Ukrainian locale and keeps it in the session", %{conn: conn} do
|
test "GET /safety selects Ukrainian locale and keeps it in the session", %{conn: conn} do
|
||||||
conn = get(conn, ~p"/safety?locale=uk")
|
conn = get(conn, ~p"/safety?locale=uk")
|
||||||
assert html_response(conn, 200) =~ "Правила безпеки"
|
assert html_response(conn, 200) =~ "Правила безпеки"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user