5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'app/controllers/allgood/healthcheck_controller.rb', line 5
def index
@results = run_checks
@status = @results.all? { |r| r[:success] } ? "ok" : "error"
status_code = @status == "ok" ? :ok : :service_unavailable
respond_to do |format|
format.html { render :index, status: status_code }
format.json { render json: { status: @status, checks: @results }, status: status_code }
end
rescue StandardError => e
Rails.logger.error "Allgood Healthcheck Error: #{e.message}\n#{e.backtrace.join("\n")}"
@results = [{ name: "Healthcheck Error", success: false, message: "Internal error occurred", duration: 0 }]
@status = "error"
respond_to do |format|
format.html { render :index, status: :internal_server_error }
format.json { render json: { status: @status, checks: @results }, status: :internal_server_error }
end
end
|