Add health controller
Fly.io uses '/health' to determine the application health status.
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
defmodule MusicLibraryWeb.HealthController do
|
||||
use MusicLibraryWeb, :controller
|
||||
|
||||
alias MusicLibrary.Repo
|
||||
|
||||
def index(conn, _params) do
|
||||
case Repo.query("SELECT 1") do
|
||||
{:ok, _} ->
|
||||
conn
|
||||
|> put_resp_content_type("text/html")
|
||||
|> send_resp(200, "App is running")
|
||||
|
||||
{:error, _} ->
|
||||
conn
|
||||
|> put_resp_content_type("text/html")
|
||||
|> send_resp(500, "App is not running")
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -17,6 +17,7 @@ defmodule MusicLibraryWeb.Router do
|
||||
scope "/", MusicLibraryWeb do
|
||||
pipe_through :browser
|
||||
|
||||
get "/health", HealthController, :index
|
||||
get "/images/:record_id", ImageController, :show
|
||||
|
||||
live "/", RecordLive.Index, :index
|
||||
|
||||
Reference in New Issue
Block a user