Add /health endpoint and CHECKS file for zero-downtime deploys
This commit is contained in:
parent
20ed47397b
commit
2f65c4648c
3 changed files with 20 additions and 0 deletions
5
CHECKS
Normal file
5
CHECKS
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
WAIT=5
|
||||||
|
TIMEOUT=60
|
||||||
|
ATTEMPTS=3
|
||||||
|
|
||||||
|
/health ok
|
||||||
12
lib/microwaveprop_web/controllers/health_controller.ex
Normal file
12
lib/microwaveprop_web/controllers/health_controller.ex
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
defmodule MicrowavepropWeb.HealthController do
|
||||||
|
use MicrowavepropWeb, :controller
|
||||||
|
|
||||||
|
def check(conn, _params) do
|
||||||
|
# Verify DB is reachable
|
||||||
|
Ecto.Adapters.SQL.query!(Microwaveprop.Repo, "SELECT 1")
|
||||||
|
|
||||||
|
conn
|
||||||
|
|> put_resp_content_type("text/plain")
|
||||||
|
|> send_resp(200, "ok")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -14,6 +14,9 @@ defmodule MicrowavepropWeb.Router do
|
||||||
plug :accepts, ["json"]
|
plug :accepts, ["json"]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Health check — no pipeline, minimal overhead
|
||||||
|
get "/health", MicrowavepropWeb.HealthController, :check
|
||||||
|
|
||||||
scope "/", MicrowavepropWeb do
|
scope "/", MicrowavepropWeb do
|
||||||
pipe_through :browser
|
pipe_through :browser
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue