Module: Cyclid::API::Health::Database

Defined in:
app/cyclid/controllers/health.rb

Overview

Internal database connection health check

Class Method Summary collapse

Class Method Details

.statusObject

Check that ActiveRecord can connect to the database



80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'app/cyclid/controllers/health.rb', line 80

def self.status
  connected = begin
                ActiveRecord::Base.connection_pool.with_connection(&:active?)
              rescue
                false
              end

  if connected
    SinatraHealthCheck::Status.new(:ok, 'database connection is okay')
  else
    SinatraHealthCheck::Status.new(:error, 'database is not connected')
  end
end