2017-04-07 06:27:15 -04:00
|
|
|
module Gitlab
|
|
|
|
module HealthChecks
|
|
|
|
class DbCheck
|
|
|
|
extend SimpleAbstractCheck
|
|
|
|
|
|
|
|
class << self
|
|
|
|
private
|
|
|
|
|
|
|
|
def metric_prefix
|
|
|
|
'db_ping'
|
|
|
|
end
|
|
|
|
|
2017-08-24 13:02:27 -04:00
|
|
|
def successful?(result)
|
2017-04-07 06:27:15 -04:00
|
|
|
result == '1'
|
|
|
|
end
|
|
|
|
|
|
|
|
def check
|
|
|
|
catch_timeout 10.seconds do
|
|
|
|
if Gitlab::Database.postgresql?
|
|
|
|
ActiveRecord::Base.connection.execute('SELECT 1 as ping')&.first&.[]('ping')
|
|
|
|
else
|
|
|
|
ActiveRecord::Base.connection.execute('SELECT 1 as ping')&.first&.first&.to_s
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|