healthchecker 1.1.2 → 1.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b2c42adf9ab5a9dd7f02441d11b3e4a24c14555
|
4
|
+
data.tar.gz: 1b1f902feb8f5f38e29504746eab2f510420ca3c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 45eb13eb6df288f250858b7d1108efc5de42598a4e4170e75ba7b343cc9a1f08d124f8424bcb43116e65d0812e02d3afb8f3162d8105c59afbb83107c2c71e10
|
7
|
+
data.tar.gz: 3d9a9d5fdec0ce8060862d897a9d61a81c08e584cef6d09a219f48205c78624d8a2bad96884fdd41701982ab7ab6cb4c2e31e6ae6c43ea6e9858c0fd7593dcfd
|
@@ -6,19 +6,53 @@ module Healthchecker
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def current_status
|
9
|
+
Healthchecker.configuration.metrics.reduce(uptime) { |status, metric|
|
10
|
+
if ConfigurableMetrics.method_defined? metric
|
11
|
+
status = status.merge(ConfigurableMetrics.send metric)
|
12
|
+
else
|
13
|
+
supported_metrics = ConfigurableMetrics.public_instance_methods
|
14
|
+
message = "#{metric} is not a supported metric. Supported metrics are #{supported_metrics}"
|
15
|
+
raise Healthchecker::ConfigurationError, message
|
16
|
+
end
|
17
|
+
status
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
def uptime
|
9
22
|
{
|
10
|
-
|
11
|
-
ok: (Redis.current.ping == 'PONG'),
|
12
|
-
config: Redis.current.client.options,
|
13
|
-
},
|
14
|
-
resque_redis: {
|
15
|
-
ok: (Resque.redis.ping == 'PONG'),
|
16
|
-
config: Resque.redis.client.options,
|
17
|
-
},
|
18
|
-
uptime: (Time.now - Healthchecker::APPLICATION_STARTED_AT),
|
23
|
+
uptime: Time.now - Healthchecker::APPLICATION_STARTED_AT
|
19
24
|
}
|
20
25
|
end
|
21
26
|
|
27
|
+
module ConfigurableMetrics
|
28
|
+
def redis
|
29
|
+
{
|
30
|
+
redis: {
|
31
|
+
ok: Redis.current.ping == 'PONG',
|
32
|
+
config: Redis.current.client.options
|
33
|
+
}
|
34
|
+
}
|
35
|
+
end
|
22
36
|
|
37
|
+
def resque
|
38
|
+
{
|
39
|
+
resque_redis: {
|
40
|
+
ok: Resque.redis.ping == 'PONG',
|
41
|
+
config: Resque.redis.client.options
|
42
|
+
}
|
43
|
+
}
|
44
|
+
end
|
45
|
+
|
46
|
+
def sidekiq
|
47
|
+
redis = Sidekiq.redis { |conn| conn }
|
48
|
+
|
49
|
+
{
|
50
|
+
sidekiq_redis: {
|
51
|
+
ok: redis.ping == 'PONG',
|
52
|
+
config: redis.client.options
|
53
|
+
}
|
54
|
+
}
|
55
|
+
end
|
56
|
+
end
|
23
57
|
end
|
24
58
|
end
|
@@ -5,7 +5,7 @@ module Healthchecker::Checks
|
|
5
5
|
|
6
6
|
def client
|
7
7
|
if options[:rsolr_client]
|
8
|
-
options[:rsolr_client]
|
8
|
+
options[:rsolr_client]
|
9
9
|
elsif options[:url]
|
10
10
|
RSolr.connect(url: options[:url])
|
11
11
|
else
|
@@ -14,8 +14,11 @@ module Healthchecker::Checks
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def check!
|
17
|
+
msg = "Could not connect to solr"
|
17
18
|
ping_success = client.head("admin/ping", :headers => {"Cache-Control" => "If-None-Match"}).response[:status] == 200
|
18
|
-
raise
|
19
|
+
raise msg unless ping_success
|
20
|
+
rescue => e
|
21
|
+
raise msg
|
19
22
|
end
|
20
23
|
end
|
21
24
|
end
|
data/lib/healthchecker.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
require
|
1
|
+
require 'healthchecker/engine'
|
2
|
+
require 'healthchecker/configuration'
|
2
3
|
require 'healthchecker/check'
|
3
4
|
require 'healthchecker/checks/redis'
|
4
5
|
require 'healthchecker/checks/migration'
|
@@ -12,6 +13,11 @@ module Healthchecker
|
|
12
13
|
APPLICATION_STARTED_AT = Time.now
|
13
14
|
|
14
15
|
mattr_accessor :checks
|
16
|
+
|
17
|
+
class << self
|
18
|
+
attr_writer :configuration
|
19
|
+
end
|
20
|
+
|
15
21
|
self.checks = []
|
16
22
|
|
17
23
|
def self.add_check(name_or_class, options={})
|
@@ -22,6 +28,20 @@ module Healthchecker
|
|
22
28
|
self.checks.map(&:perform_check).compact
|
23
29
|
end
|
24
30
|
|
31
|
+
def self.configuration
|
32
|
+
@configuration ||= Configuration.new
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.reset
|
36
|
+
@configuration = Configuration.new
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.configure
|
40
|
+
yield(configuration)
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
25
45
|
def self.lookup_class(name_or_class)
|
26
46
|
return name_or_class if name_or_class.respond_to?(:new)
|
27
47
|
"Healthchecker::Checks::#{name_or_class.to_s.capitalize}".constantize
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: healthchecker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Will Bryant
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-03-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -120,6 +120,7 @@ files:
|
|
120
120
|
- lib/healthchecker/checks/redis.rb
|
121
121
|
- lib/healthchecker/checks/s3.rb
|
122
122
|
- lib/healthchecker/checks/solr.rb
|
123
|
+
- lib/healthchecker/configuration.rb
|
123
124
|
- lib/healthchecker/engine.rb
|
124
125
|
- lib/healthchecker/version.rb
|
125
126
|
- lib/tasks/healthchecker_tasks.rake
|
@@ -143,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
143
144
|
version: '0'
|
144
145
|
requirements: []
|
145
146
|
rubyforge_project:
|
146
|
-
rubygems_version: 2.
|
147
|
+
rubygems_version: 2.6.14
|
147
148
|
signing_key:
|
148
149
|
specification_version: 4
|
149
150
|
summary: Standardized, healthcheck end-point for rails apps
|