diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-16 15:06:32 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-16 15:06:32 +0300 |
commit | d2ffc30fd583e86d4122bb5061098f4f3ca7b3f1 (patch) | |
tree | cb29c77a3ea49eb8ec732b0e644ed6cfad4770d9 /lib/gitlab/metrics/exporter | |
parent | 914ea32e0efca21436220df2c10e1bfbe4ed3da9 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/metrics/exporter')
-rw-r--r-- | lib/gitlab/metrics/exporter/base_exporter.rb | 20 | ||||
-rw-r--r-- | lib/gitlab/metrics/exporter/web_exporter.rb | 10 |
2 files changed, 25 insertions, 5 deletions
diff --git a/lib/gitlab/metrics/exporter/base_exporter.rb b/lib/gitlab/metrics/exporter/base_exporter.rb index 3aac18f59c6..13483e437d8 100644 --- a/lib/gitlab/metrics/exporter/base_exporter.rb +++ b/lib/gitlab/metrics/exporter/base_exporter.rb @@ -6,6 +6,8 @@ module Gitlab class BaseExporter < Daemon attr_reader :server + attr_accessor :additional_checks + def enabled? settings.enabled end @@ -32,12 +34,10 @@ module Gitlab Port: settings.port, BindAddress: settings.address, Logger: logger, AccessLog: access_log) server.mount_proc '/readiness' do |req, res| - render_probe( - ::Gitlab::HealthChecks::Probes::Readiness.new, req, res) + render_probe(readiness_probe, req, res) end server.mount_proc '/liveness' do |req, res| - render_probe( - ::Gitlab::HealthChecks::Probes::Liveness.new, req, res) + render_probe(liveness_probe, req, res) end server.mount '/', Rack::Handler::WEBrick, rack_app @@ -52,8 +52,10 @@ module Gitlab def stop_working if server + # we close sockets if thread is not longer running + # this happens, when the process forks + server.listeners.each(&:close) unless thread.alive? server.shutdown - server.listeners.each(&:close) end @server = nil @@ -67,6 +69,14 @@ module Gitlab end end + def readiness_probe + ::Gitlab::HealthChecks::Probes::Readiness.new(*additional_checks) + end + + def liveness_probe + ::Gitlab::HealthChecks::Probes::Liveness.new + end + def render_probe(probe, req, res) result = probe.execute diff --git a/lib/gitlab/metrics/exporter/web_exporter.rb b/lib/gitlab/metrics/exporter/web_exporter.rb index fac7043352a..f4b42759fb9 100644 --- a/lib/gitlab/metrics/exporter/web_exporter.rb +++ b/lib/gitlab/metrics/exporter/web_exporter.rb @@ -7,6 +7,16 @@ module Gitlab module Metrics module Exporter class WebExporter < BaseExporter + # This exporter is always run on master process + def initialize + super + + self.additional_checks = [ + Gitlab::HealthChecks::PumaCheck, + Gitlab::HealthChecks::UnicornCheck + ] + end + def settings Settings.monitoring.web_exporter end |