health-monitor-rails 12.3.0 → 12.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 952a62b089d3b56df2b8ab11b329dae2512d285db4027bde6705892e171ff755
4
- data.tar.gz: 36a7996a83a871a82814caef5d31d2cc880b1f40bd12e2f191290e72a9d1537f
3
+ metadata.gz: 8b3587a34b753e20332f2ee30e5a8fabf95485edc28dbf0521be42895bc2dbb0
4
+ data.tar.gz: 4b9b77a3c16bb5d01182af1ff1d327deb0089785da6905012a498be977b20038
5
5
  SHA512:
6
- metadata.gz: a9878debcd730c9848ec50af8ed0b1ed912adffc240c1aab657c82a40e0113ac32a335f53ef32c9c7a3487eee68483235b767009e900c376eb1df55dd28cf2cd
7
- data.tar.gz: d361fd7cf5fe894de0d2bce196b06c23f9c3015d1dfa545ba0158c441e2c4f1caed1d6053975a9ff545082025ec1a1c387644a7aaa4dbede0e020c8869289cac
6
+ metadata.gz: 808e2ed0c5fa88496ff3eae0540e559b871629970210ea371f0cbf95ad8e71f2f9687e72bb802b6f26b961bb59dcc42c0c904a5f6a68af9754d172c5e42ccbfb
7
+ data.tar.gz: 6d31d3cf3605c2d3eddd144242794774db6abaf7022b2cbf8cb7430ba8495d38ac81018ea97a6d516258a190dd3933e031b52103e036538a60c7d3694e36af96
data/README.md CHANGED
@@ -2,7 +2,6 @@
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/health-monitor-rails.svg)](http://badge.fury.io/rb/health-monitor-rails)
4
4
  [![Build Status](https://github.com/lbeder/health-monitor-rails/actions/workflows/ci.yml/badge.svg)](https://github.com/lbeder/health-monitor-rails/actions/workflows/ci.yml)
5
- [![Coverage Status](https://coveralls.io/repos/lbeder/health-monitor-rails/badge.svg)](https://coveralls.io/r/lbeder/health-monitor-rails)
6
5
 
7
6
  This is a health monitoring Rails mountable plug-in, which checks various services (db, cache, sidekiq, redis, etc.).
8
7
 
@@ -177,6 +176,7 @@ The following services are currently supported:
177
176
  * Resque
178
177
  * Delayed Job
179
178
  * Solr
179
+ * FileAbsence
180
180
 
181
181
  ## Configuration
182
182
 
@@ -318,6 +318,12 @@ Please note that `url` or `connection` can't be used at the same time.
318
318
  * `url`: the URL used to connect to your Solr instance - must be a string. You can also use `url` to explicitly configure authentication (e.g., `'https://user:pass@example.solr.com:8983/'`)
319
319
  * `collection`: An optional parameter used to connect to your specific Solr collection - must be a string. By setting this parameter the code will check the status of this individual collection in your Solr instance instead of just the status of the overall Solr instance
320
320
 
321
+ ### FileAbsence
322
+
323
+ This check allows you to create a file on your server when you would like to force the check to fail. For example if you are utilizing the `health.json` as you health check page for your load balancer and would like to force a machine offline.
324
+
325
+ * `filename`: the file relative to the rails root that must remain absent for the health check to remain passing. For example: `public/remove-from-nginx`
326
+
321
327
  ### Adding a Custom Provider
322
328
 
323
329
  It's also possible to add custom health check providers suited for your needs (of course, it's highly appreciated and encouraged if you'd contribute useful providers to the project).
@@ -441,9 +447,11 @@ nicolas@desktop:$ echo $?
441
447
  ```
442
448
 
443
449
  ## Development
450
+
444
451
  In order to work on development on the gem itself
445
452
 
446
453
  ### Installing the gems
454
+
447
455
  Use the [appraisal gem](https://github.com/thoughtbot/appraisal) to install the bundles for different rails versions:
448
456
 
449
457
  ```bash
@@ -453,7 +461,9 @@ appraisal install
453
461
  ```
454
462
 
455
463
  ### Running the tests
464
+
456
465
  Use appraisal to run the tests using rake
466
+
457
467
  ```bash
458
468
  appraisal rake
459
469
  ```
@@ -2,7 +2,7 @@
2
2
 
3
3
  module HealthMonitor
4
4
  class Configuration
5
- PROVIDERS = %i[cache database delayed_job redis resque sidekiq solr].freeze
5
+ PROVIDERS = %i[cache database delayed_job file_absence redis resque sidekiq solr].freeze
6
6
 
7
7
  attr_accessor :basic_auth_credentials,
8
8
  :environment_variables,
@@ -8,7 +8,7 @@ module HealthMonitor
8
8
 
9
9
  class Cache < Base
10
10
  def check!
11
- time = Time.now.to_s
11
+ time = Time.now.to_formatted_s(:rfc2822)
12
12
 
13
13
  Rails.cache.write(key, time)
14
14
  fetched = Rails.cache.read(key)
@@ -11,7 +11,7 @@ module HealthMonitor
11
11
  failed_databases = []
12
12
 
13
13
  ActiveRecord::Base.connection_handler.connection_pool_list(:all).each do |cp|
14
- cp.connection.execute('SELECT 1')
14
+ cp.lease_connection.execute('SELECT 1')
15
15
  rescue Exception
16
16
  failed_databases << cp.db_config.name
17
17
  end
@@ -14,7 +14,7 @@ module HealthMonitor
14
14
  attr_accessor :queue_size
15
15
 
16
16
  def initialize(provider)
17
- super(provider)
17
+ super
18
18
 
19
19
  @queue_size = DEFAULT_QUEUES_SIZE
20
20
  end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'health_monitor/providers/base'
4
+
5
+ module HealthMonitor
6
+ module Providers
7
+ class FileAbsenceException < StandardError; end
8
+
9
+ class FileAbsence < Base
10
+ class Configuration < Base::Configuration
11
+ DEFAULT_FILENAME = nil
12
+ attr_accessor :filename
13
+
14
+ def initialize(provider)
15
+ super
16
+
17
+ @filename = DEFAULT_FILENAME
18
+ end
19
+ end
20
+
21
+ def check!
22
+ return unless File.exist?(configuration.filename)
23
+
24
+ raise FileAbsenceException.new("Unwanted file #{configuration.filename} exists!")
25
+ end
26
+
27
+ private
28
+
29
+ def configuration_class
30
+ ::HealthMonitor::Providers::FileAbsence::Configuration
31
+ end
32
+ end
33
+ end
34
+ end
@@ -15,7 +15,7 @@ module HealthMonitor
15
15
  attr_accessor :url, :connection, :max_used_memory
16
16
 
17
17
  def initialize(provider)
18
- super(provider)
18
+ super
19
19
 
20
20
  @url = DEFAULT_URL
21
21
  end
@@ -18,7 +18,7 @@ module HealthMonitor
18
18
  attr_reader :queues
19
19
 
20
20
  def initialize(provider)
21
- super(provider)
21
+ super
22
22
 
23
23
  @maximum_amount_of_retries = DEFAULT_RETRY_CHECK
24
24
 
@@ -13,7 +13,7 @@ module HealthMonitor
13
13
  attr_accessor :url, :collection
14
14
 
15
15
  def initialize(provider)
16
- super(provider)
16
+ super
17
17
 
18
18
  @url = DEFAULT_URL
19
19
  @collection = DEFAULT_COLLECTION
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module HealthMonitor
4
- VERSION = '12.3.0'
4
+ VERSION = '12.4.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: health-monitor-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 12.3.0
4
+ version: 12.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leonid Beder
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-08-22 00:00:00.000000000 Z
11
+ date: 2024-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -45,6 +45,7 @@ files:
45
45
  - lib/health_monitor/providers/cache.rb
46
46
  - lib/health_monitor/providers/database.rb
47
47
  - lib/health_monitor/providers/delayed_job.rb
48
+ - lib/health_monitor/providers/file_absence.rb
48
49
  - lib/health_monitor/providers/redis.rb
49
50
  - lib/health_monitor/providers/resque.rb
50
51
  - lib/health_monitor/providers/sidekiq.rb
@@ -70,7 +71,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
70
71
  - !ruby/object:Gem::Version
71
72
  version: '0'
72
73
  requirements: []
73
- rubygems_version: 3.1.6
74
+ rubygems_version: 3.4.19
74
75
  signing_key:
75
76
  specification_version: 4
76
77
  summary: Health monitoring Rails plug-in, which checks various services (db, cache,