about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--Gemfile1
-rw-r--r--Gemfile.lock3
-rw-r--r--app/controllers/application_controller.rb2
-rw-r--r--config/initializers/health_check.rb6
-rw-r--r--config/routes.rb2
-rw-r--r--docker-compose.yml4
6 files changed, 15 insertions, 3 deletions
diff --git a/Gemfile b/Gemfile
index e38a2edbd..af187d364 100644
--- a/Gemfile
+++ b/Gemfile
@@ -49,6 +49,7 @@ gem 'goldfinger', '~> 2.1'
 gem 'hiredis', '~> 0.6'
 gem 'redis-namespace', '~> 1.5'
 gem 'html2text'
+gem 'health_check', '~> 3.0'
 gem 'htmlentities', '~> 4.3'
 gem 'http', '~> 3.3'
 gem 'http_accept_language', '~> 2.1'
diff --git a/Gemfile.lock b/Gemfile.lock
index 270d9e4da..e108bf497 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -288,6 +288,8 @@ GEM
       concurrent-ruby (~> 1.0)
     hashdiff (1.0.0)
     hashie (3.6.0)
+    health_check (3.0.0)
+      railties (>= 5.0)
     heapy (0.1.4)
     highline (2.0.3)
     hiredis (0.6.3)
@@ -745,6 +747,7 @@ DEPENDENCIES
   fuubar (~> 2.4)
   goldfinger (~> 2.1)
   hamlit-rails (~> 0.2)
+  health_check (~> 3.0)
   hiredis (~> 0.6)
   html2text
   htmlentities (~> 4.3)
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 7d1c532e5..78f866650 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -40,7 +40,7 @@ class ApplicationController < ActionController::Base
   private
 
   def https_enabled?
-    Rails.env.production?
+    Rails.env.production? && !request.path.start_with?('/health')
   end
 
   def authorized_fetch_mode?
diff --git a/config/initializers/health_check.rb b/config/initializers/health_check.rb
new file mode 100644
index 000000000..eece67b10
--- /dev/null
+++ b/config/initializers/health_check.rb
@@ -0,0 +1,6 @@
+HealthCheck.setup do |config|
+  config.uri = 'health'
+
+  config.standard_checks = %w(database migrations cache)
+  config.full_checks = %w(database migrations cache)
+end
diff --git a/config/routes.rb b/config/routes.rb
index 26e5f3d09..b76b9f82e 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -9,6 +9,8 @@ Sidekiq::Web.set :session_secret, Rails.application.secrets[:secret_key_base]
 Rails.application.routes.draw do
   mount LetterOpenerWeb::Engine, at: 'letter_opener' if Rails.env.development?
 
+  health_check_routes
+
   authenticate :user, lambda { |u| u.admin? } do
     mount Sidekiq::Web, at: 'sidekiq', as: :sidekiq
     mount PgHero::Engine, at: 'pghero', as: :pghero
diff --git a/docker-compose.yml b/docker-compose.yml
index 740684966..20649e424 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -43,7 +43,7 @@ services:
       - external_network
       - internal_network
     healthcheck:
-      test: ["CMD-SHELL", "wget -q --spider --header 'x-forwarded-proto: https' --proxy=off localhost:3000/api/v1/instance || exit 1"]
+      test: ["CMD-SHELL", "wget -q --spider --proxy=off localhost:3000/health || exit 1"]
     ports:
       - "127.0.0.1:3000:3000"
     depends_on:
@@ -63,7 +63,7 @@ services:
       - external_network
       - internal_network
     healthcheck:
-      test: ["CMD-SHELL", "wget -q --spider --header 'x-forwarded-proto: https' --proxy=off localhost:4000/api/v1/streaming/health || exit 1"]
+      test: ["CMD-SHELL", "wget -q --spider --proxy=off localhost:4000/api/v1/streaming/health || exit 1"]
     ports:
       - "127.0.0.1:4000:4000"
     depends_on: