2019-10-16 08:06:32 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Gitlab
|
|
|
|
module HealthChecks
|
|
|
|
# This check can only be run on Puma `master` process
|
|
|
|
class PumaCheck
|
|
|
|
extend SimpleAbstractCheck
|
|
|
|
|
|
|
|
class << self
|
|
|
|
private
|
|
|
|
|
|
|
|
def metric_prefix
|
|
|
|
'puma_check'
|
|
|
|
end
|
|
|
|
|
|
|
|
def successful?(result)
|
|
|
|
result > 0
|
|
|
|
end
|
|
|
|
|
|
|
|
def check
|
2019-12-22 04:07:51 -05:00
|
|
|
return unless Gitlab::Runtime.puma?
|
2019-10-16 08:06:32 -04:00
|
|
|
|
|
|
|
stats = Puma.stats
|
2020-04-30 20:09:59 -04:00
|
|
|
stats = Gitlab::Json.parse(stats)
|
2019-10-16 08:06:32 -04:00
|
|
|
|
|
|
|
# If `workers` is missing this means that
|
|
|
|
# Puma server is running in single mode
|
|
|
|
stats.fetch('workers', 1)
|
|
|
|
rescue NoMethodError
|
|
|
|
# server is not ready
|
|
|
|
0
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|