I wrote application in Rails. It use Postgresql via VPN. Sometimes VPN is going down and database is not available. How I can check connection with database to avoid error on web page ?
Error :
PG::ConnectionBad
could not connect to server: Connection timed out Is the server running on host "192.168.251.6" and accepting TCP/IP connections on port 5432?
Extracted source (around line #651):
# connected server's characteristics.
def connect
@connection = PGconn.connect(@connection_parameters)
# Money type has a fixed precision of 10 in PostgreSQL 8.2 and below, and as of
# PostgreSQL 8.3 it has a fixed precision of 19. PostgreSQLColumn.extract_precision
Any ideas ? And where to check because error is before any controller I think.
ActiveRecord::Base.connected?
? – Deep Jan 9 at 8:48