diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-07 18:05:59 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-07 18:05:59 +0300 |
commit | 31040b5bfe48f8d73830f473513164427522b3a6 (patch) | |
tree | 6301b395ad45d7a0f84aa0f9c31373889208d09b /lib/gitlab/metrics/exporter | |
parent | 185f428fa5e6123ffa0f29e307523da138e7b028 (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 | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/lib/gitlab/metrics/exporter/base_exporter.rb b/lib/gitlab/metrics/exporter/base_exporter.rb index de7870dfb8c..b56770e224b 100644 --- a/lib/gitlab/metrics/exporter/base_exporter.rb +++ b/lib/gitlab/metrics/exporter/base_exporter.rb @@ -31,7 +31,15 @@ module Gitlab @server = ::WEBrick::HTTPServer.new( Port: settings.port, BindAddress: settings.address, Logger: logger, AccessLog: access_log) - server.mount "/", Rack::Handler::WEBrick, rack_app + server.mount_proc '/readiness' do |req, res| + render_probe( + ::Gitlab::HealthChecks::Probes::Readiness.new, req, res) + end + server.mount_proc '/liveness' do |req, res| + render_probe( + ::Gitlab::HealthChecks::Probes::Liveness.new, req, res) + end + server.mount '/', Rack::Handler::WEBrick, rack_app server.start end @@ -51,6 +59,14 @@ module Gitlab run -> (env) { [404, {}, ['']] } end end + + def render_probe(probe, req, res) + result = probe.execute + + res.status = result.http_status + res.content_type = 'application/json; charset=utf-8' + res.body = result.json.to_json + end end end end |