Enable Rails built-in health check endpoint at /up#92
Merged
Conversation
Mounts Rails::HealthController#show at /up (rails_health_check). Returns 200 when the app boots cleanly, 500 otherwise. The controller responds with an HTML page for browsers/uptime bots and a JSON body for Accept: application/json clients, so load balancers, monitors, and JSON consumers share one endpoint. No custom controller.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Enables Rails' built-in health check endpoint at
/upby mountingRails::HealthController#show:No custom controller. This is the framework's own one-size-fits-all health check, introduced in Rails 7.1.
Why
Uptime monitors, load balancers, and container orchestrators need a stable endpoint to poll. The built-in controller returns
200when the app boots with no exceptions and500otherwise.Behavior
The controller responds to all three request styles we need, from a single route:
Accept: text/html(browser)200, green HTML pageAccept: application/json200,{"status":"up","timestamp":...}Accept/*/*200, HTML pageVerified locally against a booted server (all
200). Nohost_authorizationorallow_browserguard blocks it, and it runs as a standaloneActionController::Base, soprotect_from_forgery/ CSRF does not apply.Notes
Per the Rails docs, this endpoint reflects only that the app booted, not the status of downstream dependencies (DB, S3). That is the intended scope of
rails/health#show; a dependency-aware check would need a custom action, which is deliberately out of scope here.