diff --git a/Gemfile b/Gemfile index a54271a4..0e61e651 100644 --- a/Gemfile +++ b/Gemfile @@ -19,7 +19,7 @@ gem 'ed25519', '~> 1.3' gem 'faraday', '~> 2.7' gem "flipflop", git: "https://github.com/voormedia/flipflop.git", ref: "0d70d8e33483a9c0282ed8d6bca9c5ccd61e61e8" gem 'foreman' -gem "health-monitor-rails" +gem "health-monitor-rails", "12.4.0" gem 'honeybadger' gem 'icalendar' # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder diff --git a/Gemfile.lock b/Gemfile.lock index be33543d..3cd2b5ea 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -228,7 +228,7 @@ GEM activesupport (>= 6.1) hashdiff (1.1.0) hashie (5.0.0) - health-monitor-rails (12.3.0) + health-monitor-rails (12.4.0) railties (>= 6.1) honeybadger (5.13.0) httparty (0.22.0) @@ -546,6 +546,7 @@ PLATFORMS arm64-darwin-21 arm64-darwin-22 arm64-darwin-23 + arm64-darwin-24 x86_64-darwin-21 x86_64-linux @@ -572,7 +573,7 @@ DEPENDENCIES faraday (~> 2.7) flipflop! foreman - health-monitor-rails + health-monitor-rails (= 12.4.0) honeybadger icalendar jbuilder (~> 2.5) diff --git a/config/deploy.rb b/config/deploy.rb index bf67e81d..d0a013ea 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -13,7 +13,34 @@ # Default value for :format is :airbrussh. # set :format, :airbrussh +# +# # You can/ should apply this command to a subset of hosts +# cap --hosts=lib-jobs-staging2.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 + raise "You must run this command on individual servers utilizing the --hosts= switch" if count > (roles(:app).length / 2) + 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 subset of hosts +# cap --hosts=lib-jobs-staging2.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 +before "deploy:reverted", "deploy:assets:precompile" # You can configure the Airbrussh format using :format_options. # These are the defaults. # set :format_options, command_output: true, log_file: "log/capistrano.log", color: :auto, truncate: :auto diff --git a/config/initializers/health_monitor.rb b/config/initializers/health_monitor.rb index 93a68bfd..a1e258bc 100644 --- a/config/initializers/health_monitor.rb +++ b/config/initializers/health_monitor.rb @@ -6,9 +6,13 @@ # Make this health check available at /health config.path = :health + config.file_absence.configure do |file_config| + file_config.filename = "public/remove-from-nginx" + end + config.error_callback = proc do |e| Rails.logger.error "Health check failed with: #{e.message}" - Honeybadger.notify(e) + Honeybadger.notify(e) unless e.is_a?(HealthMonitor::Providers::FileAbsenceException) end end end