Add /health endpoint for Kubernetes probes
Create HealthController that returns 200 OK for health checks. Route is outside browser pipeline to avoid SSL redirect and authentication requirements.
This commit is contained in:
parent
aed28de923
commit
72c260e122
3 changed files with 15 additions and 1 deletions
|
|
@ -8,7 +8,7 @@ defmodule Towerops.Application do
|
|||
@impl true
|
||||
def start(_type, _args) do
|
||||
# Run migrations on startup (Ecto handles locking for concurrent runs)
|
||||
unless Application.get_env(:towerops, Towerops.Repo)[:database] == "towerops_test" do
|
||||
if Application.get_env(:towerops, Towerops.Repo)[:database] != "towerops_test" do
|
||||
Towerops.Release.migrate()
|
||||
end
|
||||
|
||||
|
|
|
|||
9
lib/towerops_web/controllers/health_controller.ex
Normal file
9
lib/towerops_web/controllers/health_controller.ex
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
defmodule ToweropsWeb.HealthController do
|
||||
use ToweropsWeb, :controller
|
||||
|
||||
def index(conn, _params) do
|
||||
conn
|
||||
|> put_resp_content_type("text/plain")
|
||||
|> send_resp(200, "ok")
|
||||
end
|
||||
end
|
||||
|
|
@ -18,6 +18,11 @@ defmodule ToweropsWeb.Router do
|
|||
plug :accepts, ["json"]
|
||||
end
|
||||
|
||||
# Health check endpoint for Kubernetes probes (no authentication required)
|
||||
scope "/", ToweropsWeb do
|
||||
get "/health", HealthController, :index
|
||||
end
|
||||
|
||||
scope "/", ToweropsWeb do
|
||||
pipe_through :browser
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue