2019-02-15 15:39:39 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
module Gitlab
|
|
|
|
module HealthChecks
|
|
|
|
class DbCheck
|
|
|
|
extend SimpleAbstractCheck
|
|
|
|
|
|
|
|
class << self
|
|
|
|
private
|
|
|
|
|
|
|
|
def metric_prefix
|
|
|
|
'db_ping'
|
|
|
|
end
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
def successful?(result)
|
2017-08-17 22:00:37 +05:30
|
|
|
result == '1'
|
|
|
|
end
|
|
|
|
|
|
|
|
def check
|
|
|
|
catch_timeout 10.seconds do
|
|
|
|
if Gitlab::Database.postgresql?
|
2018-11-08 19:23:39 +05:30
|
|
|
ActiveRecord::Base.connection.execute('SELECT 1 as ping')&.first&.[]('ping')&.to_s
|
2017-08-17 22:00:37 +05:30
|
|
|
else
|
|
|
|
ActiveRecord::Base.connection.execute('SELECT 1 as ping')&.first&.first&.to_s
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|