I am trying to do a simple health check on my postgres database for elixir.
In rails I would do something like: ActiveRecord::Base.verify_active_connections
Is there anything similar on elixir?
This is the best that I found.
status = try do
Ecto.Adapters.SQL.query(ProjectName.Repo, "select 1", [])
:ok
rescue
DBConnection.ConnectionError -> :error
end
It just sends a select 1
request to the sql server and if we get an exit we return :error
else we return :ok
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With