Class: Rails::HealthController
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
::AbstractController::Rendering
- Included
DEFAULT_PROTECTED_INSTANCE_VARIABLES
::ActionController::Redirecting
- Included
::ActionController::Rendering
- Included
::ActionController::Renderers
- Included
::ActiveSupport::Callbacks
- Included
::ActionController::RequestForgeryProtection
- Included
AUTHENTICITY_TOKEN_LENGTH, CSRF_TOKEN, GLOBAL_CSRF_TOKEN_IDENTIFIER, NULL_ORIGIN_MESSAGE
::ActionController::ParamsWrapper
- Included
::ActionController::Base
- Inherited
Class Attribute Summary
::ActionController::Metal
- Inherited
::AbstractController::Base
- Inherited
.abstract? | Alias for AbstractController::Base.abstract. |
.supports_path? | Returns true if the given controller is capable of rendering a path. |
Class Method Summary
::ActionController::Base
- Inherited
.without_modules | Shortcut helper that returns all the modules included in |
::ActionController::Metal
- Inherited
.action | Returns a |
.controller_name | Returns the last part of the controller’s name, underscored, without the ending |
.dispatch | Direct dispatch to the controller. |
.make_response!, | |
.middleware | The middleware stack used by this controller. |
.new, | |
.use | Pushes the given |
::AbstractController::Base
- Inherited
.abstract, | |
.abstract! | Define a controller as abstract. |
.action_methods | A list of method names that should be considered actions. |
.clear_action_methods! | action_methods are cached and there is sometimes a need to refresh them. |
.controller_path | Returns the full controller name, underscored, without the ending Controller. |
.internal_methods | A list of all internal methods for a controller. |
.method_added | Refresh the cached action_methods when a new action_method is added. |
::ActiveSupport::DescendantsTracker
- Extended
descendants | See additional method definition at line 109. |
subclasses |
Instance Attribute Summary
::ActionController::Instrumentation
- Included
::ActionController::Rescue
- Included
#rescue_handlers, #rescue_handlers?, | |
#show_detailed_exceptions? | Override this method if you want to customize when detailed exceptions must be shown. |
::ActionController::RequestForgeryProtection
- Included
#_helper_methods, #_helper_methods?, #raise_on_missing_callback_actions, | |
#any_authenticity_token_valid? | Checks if any of the authenticity tokens from the request are valid. |
#marked_for_same_origin_verification? | If the |
#non_xhr_javascript_response? | Check for cross-origin JavaScript responses. |
#protect_against_forgery? | Checks if the controller allows forgery protection. |
#valid_request_origin? | Checks if the request originated from the same origin by looking at the Origin header. |
#verified_request? | Returns true or false if a request is verified. |
::AbstractController::Callbacks
- Included
::ActionController::StrongParameters
- Included
#params | Returns a new |
#params= | Assigns the given |
::ActionController::EtagWithFlash
- Included
::ActionController::EtagWithTemplateDigest
- Included
::ActionController::Renderers::All
- Included
::ActionView::Layouts
- Included
#action_has_layout=, | |
#action_has_layout? | Controls whether an action should be rendered using a layout. |
::ActionView::Rendering
- Included
::ActionController::Redirecting
- Included
::AbstractController::UrlFor
- Included
::ActionController::Helpers
- Included
::ActionView::ViewPaths
- Included
::ActionController::Metal
- Inherited
#content_type, #headers, #location, #media_type, #middleware_stack, #middleware_stack?, #params, #params=, | |
#performed? | Tests if render or redirect has already happened. |
#request | :attr_reader: request. |
#response | :attr_reader: response. |
#response= | Assign the response and mark it as committed. |
#response_body=, #session, #status |
::AbstractController::Base
- Inherited
#action_name | Returns the name of the action this controller is processing. |
#formats | Returns the formats that can be processed by the controller. |
#performed? | Tests if a response body is set. |
#response_body | Returns the body of the HTTP response sent by the controller. |
Instance Method Summary
::ActionController::Instrumentation
- Included
#redirect_to, #render, #send_data, #send_file, | |
#append_info_to_payload | Every time after an action is processed, this method is invoked with the payload, so you can add more information. |
#cleanup_view_runtime | A hook which allows you to clean up any time, wrongly taken into account in views, like database querying time. |
::ActiveSupport::Rescuable
- Included
#rescue_with_handler | Delegates to the class method, but uses the instance as the subject for rescue_from handlers (method calls, |
::ActionController::HttpAuthentication::Token::ControllerMethods
- Included
#authenticate_or_request_with_http_token | Authenticate using an HTTP Bearer token, or otherwise render an HTTP header requesting the client to send a Bearer token. |
#authenticate_with_http_token | Authenticate using an HTTP Bearer token. |
#request_http_token_authentication | Render an HTTP header requesting the client to send a Bearer token for authentication. |
::ActionController::HttpAuthentication::Digest::ControllerMethods
- Included
#authenticate_or_request_with_http_digest | Authenticate using an HTTP Digest, or otherwise render an HTTP header requesting the client to send a Digest. |
#authenticate_with_http_digest | Authenticate using an HTTP Digest. |
#request_http_digest_authentication | Render an HTTP header requesting the client to send a Digest for authentication. |
::ActionController::HttpAuthentication::Basic::ControllerMethods
- Included
#authenticate_or_request_with_http_basic, #authenticate_with_http_basic, #http_basic_authenticate_or_request_with, #request_http_basic_authentication |
::ActionController::DataStreaming
- Included
#send_data | Sends the given binary data to the browser. |
#send_file | Sends the file. |
::ActionController::RequestForgeryProtection
- Included
#commit_csrf_token, #initialize, #reset_csrf_token, #compare_with_global_token, #compare_with_real_token, #csrf_token_hmac, | |
#form_authenticity_param | The form’s authenticity parameter. |
#form_authenticity_token | Creates the authenticity token for the current request. |
#global_csrf_token, #handle_unverified_request, | |
#mark_for_same_origin_verification! | GET requests are checked for cross-origin JavaScript after rendering. |
#mask_token, #normalize_action_path, #per_form_csrf_token, #real_csrf_token, | |
#request_authenticity_tokens | Possible authenticity tokens sent in the request. |
#unmask_token, | |
#valid_authenticity_token? | Checks the client’s masked token to see if it matches the session token. |
#valid_per_form_csrf_token?, | |
#verify_authenticity_token | The actual before_action that is used to verify the CSRF token. |
#verify_same_origin_request | If |
#xor_byte_strings |
::ActiveSupport::Callbacks
- Included
#run_callbacks | Runs the callbacks for the given event. |
::ActionController::FormBuilder
- Included
#default_form_builder | Default form builder for the controller. |
::ActionController::MimeResponds
- Included
#respond_to | Without web-service support, an action which collects the data for displaying a list of people might look something like this: |
::ActionController::ConditionalGet
- Included
#expires_in | Sets the |
#expires_now | Sets an HTTP 1.1 |
#fresh_when | Sets the |
#http_cache_forever | Cache or yield the block. |
#no_store | Sets an HTTP 1.1 |
#stale? | Sets the |
::ActionController::Head
- Included
#head | Returns a response that has no content (merely headers). |
::ActionController::Renderers
- Included
#_render_to_body_with_renderer, | |
#render_to_body | Called by |
::ActionController::Rendering
- Included
#render | Renders a template and assigns the result to |
#render_to_string | Similar to |
::ActionView::Rendering
- Included
#initialize, #render_to_body, | |
#view_context | An instance of a view class. |
#view_context_class |
::ActionController::Redirecting
- Included
#redirect_back | Soft deprecated alias for |
#redirect_back_or_to | Redirects the browser to the page that issued the request (the referrer) if possible, otherwise redirects to the provided default fallback location. |
#redirect_to | Redirects the browser to the target specified in |
#url_from | Verifies the passed |
::ActiveSupport::Benchmarkable
- Included
#benchmark | Allows you to measure the execution time of a block in a template and records the result to the log. |
::ActionController::UrlFor
- Included
::AbstractController::UrlFor
- Included
::ActionDispatch::Routing::UrlFor
- Included
#initialize, | |
#route_for | Allows calling direct or regular named route. |
#url_for | Generate a URL based on the options provided, |
#url_options | Hook overridden in controller to add request information with |
#_routes_context, #_with_routes |
::ActionDispatch::Routing::PolymorphicRoutes
- Included
#polymorphic_path | Returns the path component of a URL for the given record. |
#polymorphic_url | Constructs a call to a named RESTful route for the given record and returns the resulting URL string. |
::ActionController::Helpers
- Included
#helpers | Provides a proxy to access helper methods from outside the view. |
::AbstractController::Helpers
- Included
::AbstractController::Translation
- Included
#l | Alias for AbstractController::Translation#localize. |
#localize | Delegates to |
#t | Alias for AbstractController::Translation#translate. |
#translate | Delegates to |
::AbstractController::Rendering
- Included
#render | Normalizes arguments and options, and then delegates to render_to_body and sticks the result in |
#render_to_body | Performs the actual template rendering. |
#render_to_string | Similar to |
#rendered_format | Returns |
#view_assigns | This method should return a hash with assigns. |
#_normalize_args | Normalize args by converting |
#_normalize_options | Normalize options. |
#_process_options | Process extra options. |
::ActionView::ViewPaths
- Included
#any_templates?, | |
#append_view_path | Append a path to the list of view paths for the current LookupContext. |
#details_for_lookup, | |
#lookup_context | LookupContext is the object responsible for holding all information required for looking up templates, i.e. view paths and details. |
#prepend_view_path | Prepend a path to the list of view paths for the current LookupContext. |
#template_exists? |
::ActionController::Metal
- Inherited
#controller_name | Delegates to the class’s |
#reset_session, | |
#url_for | Basic url_for that can be overridden for more robust functionality. |
::AbstractController::Base
- Inherited
#action_methods | Delegates to the class’s |
#available_action? | Returns true if a method for the action is available and can be dispatched, false otherwise. |
#controller_path | Delegates to the class’s |
#process | Calls the action going through the entire Action Dispatch stack. |
::ActiveSupport::Configurable
- Included
#config | Reads and writes attributes from a configuration OrderedOptions. |
Constructor Details
This class inherits a constructor from ActionController::Metal
Instance Method Details
#show
[ GitHub ]# File 'railties/lib/rails/health_controller.rb', line 38
def show render_up end