diff --git a/Gemfile b/Gemfile index c413d0eb..ee64b557 100644 --- a/Gemfile +++ b/Gemfile @@ -22,7 +22,8 @@ gem 'faraday_middleware', '~> 1.0' gem 'ffi', '>= 1.9.25' gem 'friendly_id' gem 'gyoku', '~> 1.0' -gem 'health-monitor-rails' +# Pinning to 12.4.0 due to Rails 7.1 compatibility issue in 12.4.1 +gem 'health-monitor-rails', '12.4.0' gem 'high_voltage', '~> 3.0' gem 'honeybadger' gem 'human_languages', '~> 0.7' diff --git a/Gemfile.lock b/Gemfile.lock index 96f0cca7..f51d9c28 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -296,7 +296,7 @@ GEM rexml (~> 3.0) hashdiff (1.1.1) hashie (5.0.0) - health-monitor-rails (12.1.0) + health-monitor-rails (12.4.0) railties (>= 6.1) high_voltage (3.1.2) honeybadger (5.4.1) @@ -701,7 +701,7 @@ DEPENDENCIES ffi (>= 1.9.25) friendly_id gyoku (~> 1.0) - health-monitor-rails + health-monitor-rails (= 12.4.0) high_voltage (~> 3.0) honeybadger human_languages (~> 0.7) diff --git a/config/deploy.rb b/config/deploy.rb index 4317d6ba..e610b5a9 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -61,6 +61,37 @@ end end +namespace :application do + # You can/ should apply this command to a single host + # cap --hosts=bibdata-staging1.lib.princeton.edu staging application:remove_from_nginx + desc "Marks the server(s) to be removed from the loadbalancer" + task :remove_from_nginx do + count = 0 + on roles(:app) do + count += 1 + end + if count > (roles(:app).length / 2) + raise "You must run this command on no more than half the servers utilizing the --hosts= switch" + end + on roles(:app) do + within release_path do + execute :touch, "public/remove-from-nginx" + end + end + end + + # You can/ should apply this command to a single host + # cap --hosts=bibdata-staging1.lib.princeton.edu staging application:serve_from_nginx + desc "Marks the server(s) to be added back to the loadbalancer" + task :serve_from_nginx do + on roles(:app) do + within release_path do + execute :rm, "-f public/remove-from-nginx" + end + end + end +end + after 'deploy:reverted', 'sidekiq:restart' after 'deploy:published', 'sidekiq:restart' after 'deploy:restart', 'sqs_poller:restart' diff --git a/config/initializers/health_monitor.rb b/config/initializers/health_monitor.rb index 578f14ea..d063b5b1 100644 --- a/config/initializers/health_monitor.rb +++ b/config/initializers/health_monitor.rb @@ -4,13 +4,15 @@ config.cache config.add_custom_provider(SolrStatus) + config.file_absence.configure do |file_config| + file_config.filename = "public/remove-from-nginx" + end # Make this health check available at /health config.path = :health config.error_callback = proc do |e| Rails.logger.error "Health check failed with: #{e.message}" - Honeybadger.notify(e) end end end