Class: Rails::HealthController
- Inherits:
-
ActionController::Base
- Object
- AbstractController::Base
- ActionController::Metal
- ActionController::Base
- Rails::HealthController
- Defined in:
- railties/lib/rails/health_controller.rb
Overview
Built-in Health Check Endpoint
Rails also comes with a built-in health check endpoint that is reachable at the /up
path. This endpoint will return a 200 status code if the app has booted with no exceptions, and a 500 status code otherwise.
In production, many applications are required to report their status upstream, whether it’s to an uptime monitor that will page an engineer when things go wrong, or a load balancer or Kubernetes controller used to determine a pod’s health. This health check is designed to be a one-size fits all that will work in many situations.
While any newly generated Rails applications will have the health check at /up
, you can configure the path to be anything you’d like in your "config/routes.rb"
:
Rails.application.routes.draw do
get "healthz" => "rails/health#show", as: :rails_health_check
end
The health check will now be accessible via the /healthz
path.
NOTE: This endpoint does not reflect the status of all of your application’s dependencies, such as the database or Redis cluster. Replace "rails/health#show"
with your own controller action if you have application specific needs.
Think carefully about what you want to check as it can lead to situations where your application is being restarted due to a third-party service going bad. Ideally, you should design your application to handle those outages gracefully.
Constant Summary
Constants inherited from ActionController::Base
ActionController::Base::MODULES, ActionController::Base::PROTECTED_IVARS
Constants included from ActionController::ParamsWrapper
ActionController::ParamsWrapper::EXCLUDE_PARAMETERS
Constants included from ActiveSupport::Callbacks
ActiveSupport::Callbacks::CALLBACK_FILTER_TYPES
Constants included from ActionController::DataStreaming
ActionController::DataStreaming::DEFAULT_SEND_FILE_DISPOSITION, ActionController::DataStreaming::DEFAULT_SEND_FILE_TYPE
Constants included from ActionController::Rendering
ActionController::Rendering::RENDER_FORMATS_IN_PRIORITY
Constants included from ActionController::RequestForgeryProtection
ActionController::RequestForgeryProtection::CSRF_TOKEN
Constants included from ActionController::Renderers
ActionController::Renderers::RENDERERS
Constants included from ActionController::Redirecting
ActionController::Redirecting::ILLEGAL_HEADER_VALUE_REGEX
Constants included from AbstractController::Rendering
AbstractController::Rendering::DEFAULT_PROTECTED_INSTANCE_VARIABLES
Instance Method Summary collapse
Methods inherited from ActionController::Base
Methods included from ActiveSupport::Concern
#append_features, #class_methods, extended, #included, #prepend_features, #prepended
Methods included from ActionController::Instrumentation
#initialize, #redirect_to, #render, #send_data, #send_file
Methods included from ActionController::Rescue
Methods included from ActiveSupport::Rescuable
#handler_for_rescue, #rescue_with_handler
Methods included from ActiveSupport::Callbacks
Methods included from ActionController::HttpAuthentication::Token::ControllerMethods
#authenticate_or_request_with_http_token, #authenticate_with_http_token, #request_http_token_authentication
Methods included from ActionController::HttpAuthentication::Digest::ControllerMethods
#authenticate_or_request_with_http_digest, #authenticate_with_http_digest, #request_http_digest_authentication
Methods included from ActionController::HttpAuthentication::Basic::ControllerMethods
#authenticate_or_request_with_http_basic, #authenticate_with_http_basic, #http_basic_authenticate_or_request_with, #request_http_basic_authentication
Methods included from ActionController::Rendering
#render, #render_to_body, #render_to_string
Methods included from AbstractController::Helpers
Methods included from AbstractController::Helpers::Resolution
#all_helpers_from_path, #helper_modules_from_paths, #modules_for_helpers
Methods included from ActionController::RequestForgeryProtection
#commit_csrf_token, #initialize, #reset_csrf_token
Methods included from ActionController::FormBuilder
Methods included from ActionController::StrongParameters
Methods included from ActionController::ImplicitRender
#default_render, #method_for_action
Methods included from ActionController::BasicImplicitRender
Methods included from ActionController::MimeResponds
Methods included from ActionController::ConditionalGet
#expires_in, #expires_now, #fresh_when, #http_cache_forever, #no_store, #stale?
Methods included from ActionController::Head
Methods included from ActionController::Renderers
#_render_to_body_with_renderer, _render_with_renderer_method_name, add, remove, #render_to_body
Methods included from ActionView::Layouts
#_process_render_template_options, #action_has_layout?, #initialize
Methods included from ActionView::Rendering
#initialize, #process, #render_to_body, #view_context, #view_context_class, #view_renderer
Methods included from ActionView::ViewPaths
#_prefixes, #append_view_path, #details_for_lookup, #lookup_context, #prepend_view_path
Methods included from ActionController::Redirecting
_compute_redirect_to_location, #_compute_redirect_to_location, #redirect_back, #redirect_back_or_to, #redirect_to, #url_from
Methods included from ActionController::UrlFor
Methods included from AbstractController::UrlFor
Methods included from ActionDispatch::Routing::UrlFor
#full_url_for, #initialize, #route_for, #url_for, #url_options
Methods included from ActionDispatch::Routing::PolymorphicRoutes
#polymorphic_path, #polymorphic_url
Methods included from ActionController::Helpers
Methods included from AbstractController::Translation
Methods included from AbstractController::Rendering
#render, #render_to_body, #render_to_string, #rendered_format, #view_assigns
Methods inherited from ActionController::Metal
action, action_encoding_template, #content_type, #content_type=, #controller_name, controller_name, dispatch, #dispatch, #headers, #initialize, #location, #location=, make_response!, #media_type, middleware, #params, #params=, #performed?, #request, #reset_session, #response, #response=, #response_body=, #session, #set_request!, #set_response!, #status, #status=, #to_a, #url_for, use
Methods included from ActionController::Testing::Functional
#clear_instance_variables_between_requests, #recycle!
Methods inherited from AbstractController::Base
abstract!, action_methods, #action_methods, #action_name, #available_action?, clear_action_methods!, controller_path, #controller_path, eager_load!, #formats, inherited, #inspect, internal_methods, method_added, #performed?, #process, #response_body, supports_path?
Methods included from ActiveSupport::DescendantsTracker
clear, #descendants, descendants, disable_clear!, reject!, subclasses
Methods included from ActiveSupport::Configurable
Instance Method Details
#show ⇒ Object
38 39 40 |
# File 'railties/lib/rails/health_controller.rb', line 38 def show render_up end |