Add simple health check

This commit is contained in:
Thor77 2022-06-08 18:50:54 +02:00
parent cbd80f50cb
commit 96abf0536a
No known key found for this signature in database
GPG Key ID: 5051E71B46AA669A
3 changed files with 21 additions and 5 deletions

View File

@ -0,0 +1,18 @@
# frozen_string_literal: true
class HealthController < ApplicationController
def index
errors = []
errors << 'database not conneected' unless database_connected?
status = errors.empty? ? :ok : :internal_server_error
render json: { errors: }, status:
end
private
def database_connected?
ApplicationRecord.connection.select_value('SELECT 1') == 1
rescue StandardError
false
end
end

View File

@ -34,13 +34,9 @@ spec:
secretKeyRef:
name: rails-master-key
key: master.key
livenessProbe:
httpGet:
path: /
port: http
readinessProbe:
httpGet:
path: /
path: /healthz
port: http
resources:
{{- toYaml .Values.resources | nindent 12 }}

View File

@ -17,4 +17,6 @@ Rails.application.routes.draw do
end
resources :match_scores, only: %i[show update]
resources :groups, only: %i[show]
get 'healthz', to: 'health#index'
end