From 396ed4be043d8114926d0d695787e5218a320038 Mon Sep 17 00:00:00 2001 From: Sam Ruby Date: Tue, 7 Feb 2023 14:11:03 -0500 Subject: [PATCH] Make health check autodetectable. Also have generator comment out Rails 7.1 health check. See also: * https://github.com/superfly/flyctl/pull/1678 * https://github.com/rails/rails/pull/47217 * https://github.com/rails/rails/pull/46936 --- lib/generators/healthcheck/install_generator.rb | 1 + lib/healthcheck/router.rb | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/generators/healthcheck/install_generator.rb b/lib/generators/healthcheck/install_generator.rb index 96fba58..54091e4 100644 --- a/lib/generators/healthcheck/install_generator.rb +++ b/lib/generators/healthcheck/install_generator.rb @@ -33,6 +33,7 @@ def create_initializer_file HEALTHCHECK_INITIALIZER_TEXT ) route 'Healthcheck.routes(self)' + comment_lines 'config/routes.rb', /:rails_health_check/ end end end diff --git a/lib/healthcheck/router.rb b/lib/healthcheck/router.rb index 3f0bd9a..1dd8532 100644 --- a/lib/healthcheck/router.rb +++ b/lib/healthcheck/router.rb @@ -5,7 +5,8 @@ class Router def self.mount(router) router.send( Healthcheck.configuration.method, - Healthcheck.configuration.route => 'healthcheck/healthchecks#check' + Healthcheck.configuration.route => 'healthcheck/healthchecks#check', + as: :rails_health_check ) end end