diff --git a/k8s/deployment.yaml b/k8s/deployment.yaml index b7bf638..37da4c5 100644 --- a/k8s/deployment.yaml +++ b/k8s/deployment.yaml @@ -52,14 +52,14 @@ spec: memory: 512Mi readinessProbe: httpGet: - path: / + path: /health port: 4000 - initialDelaySeconds: 10 - periodSeconds: 10 + initialDelaySeconds: 3 + periodSeconds: 3 failureThreshold: 3 livenessProbe: httpGet: - path: / + path: /health port: 4000 initialDelaySeconds: 30 periodSeconds: 30 diff --git a/lib/cobblemon_ui_web/endpoint.ex b/lib/cobblemon_ui_web/endpoint.ex index 7a3369d..37934f1 100644 --- a/lib/cobblemon_ui_web/endpoint.ex +++ b/lib/cobblemon_ui_web/endpoint.ex @@ -1,6 +1,8 @@ defmodule CobblemonUiWeb.Endpoint do use Phoenix.Endpoint, otp_app: :cobblemon_ui + plug CobblemonUiWeb.Plugs.HealthCheck + # The session will be stored in the cookie and signed, # this means its contents can be read but not tampered with. # Set :encryption_salt if you would also like to encrypt it. diff --git a/lib/cobblemon_ui_web/health_check.ex b/lib/cobblemon_ui_web/health_check.ex new file mode 100644 index 0000000..7028b9f --- /dev/null +++ b/lib/cobblemon_ui_web/health_check.ex @@ -0,0 +1,17 @@ +defmodule CobblemonUiWeb.Plugs.HealthCheck do + @moduledoc """ + A lightweight health check plug that responds before hitting the router. + This avoids unnecessary processing and logging for health check requests. + """ + import Plug.Conn + + def init(opts), do: opts + + def call(%Plug.Conn{request_path: "/health"} = conn, _opts) do + conn + |> send_resp(200, ~s({"status":"ok"})) + |> halt() + end + + def call(conn, _opts), do: conn +end