Fixed #269 Add health-check endpoint (GRN-3) (#290)

* <Added health_check endpoint>

* <changed gemfile_lock>

* <fixed code style>

* <removed excess health_check routes>
This commit is contained in:
John Ma 2018-10-12 15:57:53 -04:00 committed by Jesus Federico
parent cf2fac019e
commit a9be611d00
4 changed files with 57 additions and 0 deletions

View File

@ -66,6 +66,9 @@ gem 'http_accept_language'
# Markdown parsing.
gem 'redcarpet'
# For health check endpoint
gem "health_check"
group :production do
# Use a postgres database in production.
gem 'pg', '~> 0.18'

View File

@ -97,6 +97,8 @@ GEM
activesupport (>= 4.2.0)
hashdiff (0.3.7)
hashie (3.5.7)
health_check (3.0.0)
railties (>= 5.0)
http-cookie (1.0.3)
domain_name (~> 0.5)
http_accept_language (2.1.1)
@ -327,6 +329,7 @@ DEPENDENCIES
dotenv-rails
factory_bot_rails
faker
health_check
http_accept_language
jbuilder (~> 2.5)
jquery-rails

View File

@ -0,0 +1,49 @@
# frozen_string_literal: true
# Health check to monitor the status of the rails server
HealthCheck.setup do |config|
# uri prefix (no leading slash)
config.uri = 'health_check'
# Text output upon success
config.success = 'success'
# Timeout in seconds used when checking smtp server
config.smtp_timeout = 30.0
# http status code used when plain text error message is output
# Set to 200 if you want your want to distinguish between partial (text does not include success) and
# total failure of rails application (http status of 500 etc)
config.http_status_for_error_text = 500
# http status code used when an error object is output (json or xml)
# Set to 200 if you want your want to distinguish between partial (healthy property == false) and
# total failure of rails application (http status of 500 etc)
config.http_status_for_error_object = 500
# bucket names to test connectivity - required only if s3 check used, access permissions can be mixed
config.buckets = { 'bucket_name' => [:R, :W, :D] }
# You can customize which checks happen on a standard health check, eg to set an explicit list use:
config.standard_checks = %w(database migrations custom)
# Or to exclude one check:
config.standard_checks -= %w(emailconf)
# You can set what tests are run with the 'full' or 'all' parameter
config.full_checks = %w(database migrations custom email cache redis resque-redis sidekiq-redis s3)
# max-age of response in seconds
# cache-control is public when max_age > 1 and basic_auth_username is not set
# You can force private without authentication for longer max_age by
# setting basic_auth_username but not basic_auth_password
config.max_age = 1
# http status code used when the ip is not allowed for the request
config.http_status_for_ip_whitelist_error = 403
# When redis url is non-standard
config.redis_url = 'redis_url'
end

View File

@ -17,6 +17,8 @@
# with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
Rails.application.routes.draw do
get 'health_check', to: 'health_check/health_check#index'
# Error routes.
match '/404', to: 'errors#not_found', via: :all
match '/422', to: 'errors#unprocessable', via: :all