Skip to content
Snippets Groups Projects
Unverified Commit b4c0b2f9 authored by Ahmad Farhat's avatar Ahmad Farhat Committed by GitHub
Browse files

Fix health check destroying db connections (#5249)

parent a73a3140
Branches
Tags
No related merge requests found
...@@ -37,10 +37,7 @@ class HealthChecksController < ApplicationController ...@@ -37,10 +37,7 @@ class HealthChecksController < ApplicationController
private private
def check_database def check_database
ActiveRecord::Base.establish_connection # Establishes connection raise 'Unable to connect to Database' unless ActiveRecord::Base.connection.active?
ActiveRecord::Base.connection # Calls connection object
raise 'Unable to connect to Database' unless ActiveRecord::Base.connected?
raise 'Unable to connect to Database - pending migrations' unless ActiveRecord::Migration.check_pending!.nil? raise 'Unable to connect to Database - pending migrations' unless ActiveRecord::Migration.check_pending!.nil?
rescue StandardError => e rescue StandardError => e
raise "Unable to connect to Database - #{e}" raise "Unable to connect to Database - #{e}"
......
...@@ -32,9 +32,7 @@ namespace :configuration do ...@@ -32,9 +32,7 @@ namespace :configuration do
info 'Checking connection to Postgres Database:' info 'Checking connection to Postgres Database:'
begin begin
ActiveRecord::Base.establish_connection # Establishes connection failed('Unable to connect to Database') unless ActiveRecord::Base.connection.active?
ActiveRecord::Base.connection # Calls connection object
failed('Unable to connect to Database') unless ActiveRecord::Base.connected?
rescue StandardError => e rescue StandardError => e
failed("Unable to connect to Database - #{e}") failed("Unable to connect to Database - #{e}")
end end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment