Ecto & reacting to database becoming unavailable?

One way of doing it, is to monitor the connection processes using Process.monitor/1. You can read about a potential approach dealing with this here: How can I monitor when a process is restarted.

If you are only interested in disabling the repo when there is no connection to the database, a much easier solution is to create a process that pings the database and either starts or stops the repo supervisor.

1 Like