Last active
April 19, 2021 21:10
-
-
Save lpeppe/91c847183aba020e3fa6958b7f3b81c7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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