Skip to content

Instantly share code, notes, and snippets.

@lpeppe
Last active April 19, 2021 21:10
Show Gist options
  • Save lpeppe/91c847183aba020e3fa6958b7f3b81c7 to your computer and use it in GitHub Desktop.
Save lpeppe/91c847183aba020e3fa6958b7f3b81c7 to your computer and use it in GitHub Desktop.
defmodule PhxHealthcheck.Healthcheck.Services.Database do
alias PhxHealthcheck.{Healthcheck, Repo}
import Ecto.Adapters.SQL
@behaviour Healthcheck
def check_status() do
try do
query(Repo, "SELECT 1")
rescue
e in RuntimeError -> e
end
|> case do
{:ok, _} -> "healthy"
_ -> "unhealthy"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment