Skip to content

Commit

Permalink
add the configuration for health-monitor
Browse files Browse the repository at this point in the history
we initialize health-monitor and configure it
  • Loading branch information
kayiwa committed Nov 13, 2024
1 parent 60f98bf commit 9aea93a
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
30 changes: 30 additions & 0 deletions config/deploy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,36 @@

after :finishing, 'deploy:cleanup'

# # You can/ should apply this command to a subset of hosts
# cap --hosts=lib-approvals-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
if count > (roles(:app).length / 2)
raise "You must run this command on individual 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 subset of hosts
# cap --hosts=lib-approvals-staging2.lib.princeton.edu staging application:serve_from_nginx
desc "Marks the server(s) to be removed from 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

before "deploy:reverted", "deploy:assets:precompile"
# # We shouldn't need this because it should be built in to Rails 5.1
# # see https://github.com/rails/webpacker/issues/1037
# desc 'Run yarn install'
Expand Down
17 changes: 17 additions & 0 deletions config/initializers/health_monitor.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# frozen_string_literal: true
Rails.application.config.after_initialize do
HealthMonitor.configure do |config|
config.cache

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)
end
end
end

0 comments on commit 9aea93a

Please sign in to comment.