Skip to content

Commit

Permalink
port tootsuite#11770 to monsterfork: Add healthcheck endpoint for web
Browse files Browse the repository at this point in the history
  • Loading branch information
ykzts authored and multiple creatures committed Feb 21, 2020
1 parent 45e843d commit b9ed21b
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def raise_not_found
private

def https_enabled?
Rails.env.production?
Rails.env.production? && !request.path.start_with?('/health')
end

def authorized_fetch_mode?
Expand Down
6 changes: 6 additions & 0 deletions config/initializers/health_check.rb
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
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
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down

0 comments on commit b9ed21b

Please sign in to comment.