2018-09-14 01:42:05 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-04-07 06:27:15 -04:00
|
|
|
class HealthController < ActionController::Base
|
2018-10-09 01:59:42 -04:00
|
|
|
protect_from_forgery with: :exception, prepend: true
|
2017-07-03 11:09:34 -04:00
|
|
|
include RequiresWhitelistedMonitoringClient
|
2017-04-07 06:27:15 -04:00
|
|
|
|
|
|
|
def readiness
|
2019-10-07 11:05:59 -04:00
|
|
|
render_probe(::Gitlab::HealthChecks::Probes::Readiness)
|
2017-04-07 06:27:15 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def liveness
|
2019-10-07 11:05:59 -04:00
|
|
|
render_probe(::Gitlab::HealthChecks::Probes::Liveness)
|
2017-04-07 06:27:15 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2019-10-07 11:05:59 -04:00
|
|
|
def render_probe(probe_class)
|
|
|
|
result = probe_class.new.execute
|
|
|
|
|
|
|
|
# disable static error pages at the gitlab-workhorse level, we want to see this error response even in production
|
|
|
|
headers["X-GitLab-Custom-Error"] = 1 unless result.success?
|
|
|
|
|
|
|
|
render json: result.json, status: result.http_status
|
2017-04-07 06:27:15 -04:00
|
|
|
end
|
|
|
|
end
|