From 3456ff2bb9d4ce21d38c6e24932714c8316df29a Mon Sep 17 00:00:00 2001 From: Jesus Federico <jesus@123it.ca> Date: Tue, 21 Feb 2023 22:29:20 +0100 Subject: [PATCH] GIT-XX: making health check conditiopns configurable (#4823) --- app/controllers/health_check_controller.rb | 6 +++--- config/application.rb | 4 ++++ sample.env | 10 ++++++++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/app/controllers/health_check_controller.rb b/app/controllers/health_check_controller.rb index 8ecc0414..599eae8f 100644 --- a/app/controllers/health_check_controller.rb +++ b/app/controllers/health_check_controller.rb @@ -26,9 +26,9 @@ class HealthCheckController < ApplicationController @cache_expire = 10.seconds begin - cache_check - database_check - email_check + cache_check if Rails.configuration.health_check_cache_enabled + database_check if Rails.configuration.health_check_db_enabled + email_check if Rails.configuration.health_check_email_enabled rescue => e response = "Health Check Failure: #{e}" end diff --git a/config/application.rb b/config/application.rb index d23746fd..e91ef48a 100644 --- a/config/application.rb +++ b/config/application.rb @@ -188,5 +188,9 @@ module Greenlight config.max_avatar_size = ENV['MAX_AVATAR_SIZE'].to_i.zero? ? 100_000 : ENV['MAX_AVATAR_SIZE'].to_i config.social_switching = ENV['SOCIAL_SWITCHING'] == "true" + + config.health_check_cache_enabled = ENV.fetch('ENABLE_HEALTH_CHECK_CACHE', 'true').casecmp?('true') + config.health_check_db_enabled = ENV.fetch('ENABLE_HEALTH_CHECK_DB', 'true').casecmp?('true') + config.health_check_email_enabled = ENV.fetch('ENABLE_HEALTH_CHECK_EMAIL', 'true').casecmp?('true') end end diff --git a/sample.env b/sample.env index 601f5916..d62c0a19 100644 --- a/sample.env +++ b/sample.env @@ -371,3 +371,13 @@ MAX_AVATAR_SIZE=100000 # Due CCVE-2015-9284, this setting needs to be enabled for omniauth to respond GET requests. # ENABLE_OMNIAUTH_GET=true|<false> ENABLE_OMNIAUTH_GET=false + +# By default health_check proves the availability of CACHE, DB and EMAIL server +# but when the time of response requires is highly sensitive, in some cases it is necessary to disable +# them and relay only on the http response. In such case these env variables can be set. +# ENABLE_HEALTH_CHECK_CACHE=<true>|false +# ENABLE_HEALTH_CHECK_DB=<true>|false +# ENABLE_HEALTH_CHECK_EMAIL=<true>|false +ENABLE_HEALTH_CHECK_CACHE=true +ENABLE_HEALTH_CHECK_DB=true +ENABLE_HEALTH_CHECK_EMAIL=true -- GitLab