health_check 2.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +32 -28
- data/Gemfile +4 -9
- data/README.rdoc +21 -9
- data/lib/health_check.rb +11 -2
- data/lib/health_check/base_health_check.rb +5 -0
- data/lib/health_check/health_check_controller.rb +5 -4
- data/lib/health_check/redis_health_check.rb +15 -0
- data/lib/health_check/resque_health_check.rb +15 -0
- data/lib/health_check/s3_health_check.rb +65 -0
- data/lib/health_check/sidekiq_health_check.rb +17 -0
- data/lib/health_check/utils.rb +18 -3
- data/lib/health_check/version.rb +1 -2
- data/test/rails_4.0.gemfile +11 -1
- data/test/rails_4.1.gemfile +11 -1
- data/test/rails_4.2.gemfile +12 -1
- data/test/rails_5.0.gemfile +26 -0
- data/test/rails_edge.gemfile +8 -1
- data/test/setup_railsapp +5 -4
- data/test/test_with_railsapp +9 -2
- data/test/testurl +1 -1
- metadata +9 -2
data/.travis.yml
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
sudo: false
|
2
|
+
cache: bundler
|
1
3
|
language: ruby
|
2
4
|
notifications:
|
3
5
|
email:
|
@@ -15,32 +17,40 @@ bundler_args: "--binstubs"
|
|
15
17
|
|
16
18
|
script: ./test/test_with_railsapp
|
17
19
|
|
18
|
-
#rvm:
|
19
|
-
# - 2.2.0
|
20
|
-
|
21
|
-
#gemfile:
|
22
|
-
# - test/rails_4.2.gemfile
|
23
|
-
|
24
20
|
matrix:
|
25
21
|
allow_failures:
|
26
|
-
- rvm: 2.
|
22
|
+
- rvm: 2.3.1
|
27
23
|
gemfile: test/rails_edge.gemfile
|
28
24
|
env: RAILS_VERSION=edge
|
29
25
|
|
30
26
|
- rvm: ruby-head
|
31
|
-
gemfile: test/
|
32
|
-
env: RAILS_VERSION=
|
27
|
+
gemfile: test/rails_edge.gemfile
|
28
|
+
env: RAILS_VERSION=edge
|
29
|
+
|
30
|
+
- rvm: ruby-head
|
31
|
+
gemfile: test/rails_5.0.gemfile
|
32
|
+
env: RAILS_VERSION=5.0
|
33
33
|
|
34
34
|
include:
|
35
35
|
# ruby / rails edge
|
36
36
|
|
37
|
-
- rvm: 2.
|
37
|
+
- rvm: 2.3.1
|
38
38
|
gemfile: test/rails_edge.gemfile
|
39
39
|
env: RAILS_VERSION=edge
|
40
40
|
|
41
41
|
- rvm: ruby-head
|
42
|
-
gemfile: test/
|
43
|
-
env: RAILS_VERSION=
|
42
|
+
gemfile: test/rails_edge.gemfile
|
43
|
+
env: RAILS_VERSION=edge
|
44
|
+
|
45
|
+
# ruby 5.0 Jun. 2016
|
46
|
+
|
47
|
+
- rvm: 2.2.2
|
48
|
+
gemfile: test/rails_5.0.gemfile
|
49
|
+
env: RAILS_VERSION=5.0
|
50
|
+
|
51
|
+
- rvm: ruby-head
|
52
|
+
gemfile: test/rails_5.0.gemfile
|
53
|
+
env: RAILS_VERSION=5.0
|
44
54
|
|
45
55
|
# rails 4.2 Dec, 2014
|
46
56
|
|
@@ -52,17 +62,19 @@ matrix:
|
|
52
62
|
gemfile: test/rails_4.2.gemfile
|
53
63
|
env: RAILS_SERVER=puma RAILS_VERSION=4.2
|
54
64
|
|
55
|
-
|
56
|
-
|
57
|
-
|
65
|
+
# Can't find i18n?? because it can't compile?
|
66
|
+
#- rvm: 2.1.2
|
67
|
+
# gemfile: test/rails_4.2.gemfile
|
68
|
+
# env: RAILS_SERVER=passenger RAILS_VERSION=4.2
|
58
69
|
|
59
70
|
- rvm: 2.1.2
|
60
71
|
gemfile: test/rails_4.2.gemfile
|
61
72
|
env: RAILS_SERVER=thin RAILS_VERSION=4.2
|
62
73
|
|
63
|
-
|
64
|
-
|
65
|
-
|
74
|
+
# No longer supported by travis
|
75
|
+
#- rvm: rbx-2.2.6
|
76
|
+
# gemfile: test/rails_4.0.gemfile
|
77
|
+
# env: RAILS_ENV2=development RAILS_VERSION=4.0
|
66
78
|
|
67
79
|
- rvm: 2.1.2
|
68
80
|
gemfile: test/rails_4.2.gemfile
|
@@ -76,19 +88,11 @@ matrix:
|
|
76
88
|
|
77
89
|
- rvm: 2.1.2
|
78
90
|
gemfile: test/rails_4.1.gemfile
|
79
|
-
env:
|
91
|
+
env: RAILS_VERSION=4.1
|
80
92
|
|
81
|
-
# rails 4.0
|
93
|
+
# rails 4.0
|
82
94
|
|
83
95
|
- rvm: 1.9.3
|
84
96
|
gemfile: test/rails_4.0.gemfile
|
85
97
|
env: RAILS_VERSION=4.0
|
86
98
|
|
87
|
-
- rvm: rbx-2.2.6
|
88
|
-
gemfile: test/rails_4.0.gemfile
|
89
|
-
env: RAILS_ENV2=development RAILS_VERSION=4.0
|
90
|
-
|
91
|
-
- rvm: 2.0.0
|
92
|
-
gemfile: test/rails_4.0.gemfile
|
93
|
-
env: RAILS_VERSION=4.0
|
94
|
-
|
data/Gemfile
CHANGED
@@ -2,9 +2,6 @@ source 'https://rubygems.org'
|
|
2
2
|
|
3
3
|
# Specify your gem's dependencies in health_check.gemspec
|
4
4
|
|
5
|
-
# TODO: fix shoulda version doesn't work with ruby 2.2
|
6
|
-
ruby '1.9.3' if RUBY_VERSION > '1.9.3'
|
7
|
-
|
8
5
|
gemspec
|
9
6
|
|
10
7
|
group :development, :test do
|
@@ -12,14 +9,12 @@ group :development, :test do
|
|
12
9
|
gem 'jruby-openssl'
|
13
10
|
gem 'activerecord-jdbcsqlite3-adapter'
|
14
11
|
else
|
15
|
-
gem 'sqlite3',
|
12
|
+
gem 'sqlite3', '~> 1.3.7'
|
16
13
|
end
|
17
14
|
# run travis-lint to check .travis.yml
|
18
15
|
gem 'travis-lint'
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
end
|
16
|
+
# mime-types 2.0 requires Ruby version >= 1.9.2
|
17
|
+
# mime-types 3.0 requires Ruby version >= 2.0
|
18
|
+
gem 'mime-types', RUBY_VERSION < '1.9.2' ? '< 2.0' : (defined?(JRUBY_VERSION) || RUBY_VERSION < '2.0' ? '< 3.0' : '>= 3.0')
|
23
19
|
|
24
20
|
end
|
25
|
-
|
data/README.rdoc
CHANGED
@@ -2,7 +2,8 @@
|
|
2
2
|
|
3
3
|
Simple health check of Rails 4.x+ apps for use with Pingdom, NewRelic, EngineYard or uptime.openacs.org etc.
|
4
4
|
|
5
|
-
Use {pre_rails4}[https://github.com/ianheggie/health_check/tree/pre_rails4] branch or gem versions < 2.0 for Rails 2.3 and 3.x
|
5
|
+
Use {pre_rails4}[https://github.com/ianheggie/health_check/tree/pre_rails4] branch or gem versions < 2.0 for Rails 2.3 and 3.x;
|
6
|
+
Use {master}[https://github.com/ianheggie/health_check/tree/master] branch or gem versions ~> 2.0 for Rails 4.x and 5.x;
|
6
7
|
|
7
8
|
The basic goal is to quickly check that rails is up and running and that it has access to correctly configured resources (database, email gateway)
|
8
9
|
|
@@ -32,12 +33,18 @@ The health_check controller disables sessions for versions that eagerly load ses
|
|
32
33
|
|
33
34
|
* standard (default) - site, database and migrations checks are run plus email if ActionMailer is defined and it is not using the default configuration
|
34
35
|
* all / full - all checks are run (can be overriden in config block)
|
36
|
+
* cache - checks that a value can be written to the cache
|
37
|
+
* custom - runs checks added via config.add_custom_check
|
35
38
|
* database - checks that the current migration level can be read from the database
|
36
39
|
* email - basic check of email - :test returns true, :sendmail checks file is present and executable, :smtp sends HELO command to server and checks response
|
37
40
|
* migration - checks that the database migration level matches that in db/migrations
|
38
|
-
*
|
41
|
+
* redis\[-if-present\] - checks Redis connectivity
|
42
|
+
* resque-redis\[-if-present\] - checks Resque connectivity to Redis
|
43
|
+
* s3\[-if-present\] - checks proper permissions to s3 buckets
|
44
|
+
* sidekiq-redis\[-if-present\] - checks Sidekiq connectivity to Redis
|
39
45
|
* site - checks rails is running sufficiently to render text
|
40
|
-
|
46
|
+
|
47
|
+
Some checks have a *-if-present form, which only runs the check if the corresponding library has been required.
|
41
48
|
|
42
49
|
The email gateway is not checked unless the smtp settings have been changed.
|
43
50
|
Specify full or include email in the list of checks to verify the smtp settings
|
@@ -83,11 +90,17 @@ To change the configuration of health_check, create a file `config/initializers/
|
|
83
90
|
|
84
91
|
config.http_status_for_error_object = 500
|
85
92
|
|
86
|
-
#
|
93
|
+
# bucket names to test connectivity - required only if s3 check used, access permissions can be mixed
|
94
|
+
config.buckets = {'bucket_name' => [:R, :W, :D]}
|
95
|
+
|
96
|
+
# You can customize which checks happen on a standard health check, eg to set an explicit list use:
|
87
97
|
config.standard_checks = [ 'database', 'migrations', 'custom' ]
|
88
98
|
|
99
|
+
# Or to exclude one check:
|
100
|
+
config.standard_checks -= [ 'emailconf' ]
|
101
|
+
|
89
102
|
# You can set what tests are run with the 'full' or 'all' parameter
|
90
|
-
config.full_checks = ['database', 'migrations', 'custom', 'email', 'cache']
|
103
|
+
config.full_checks = ['database', 'migrations', 'custom', 'email', 'cache', 'redis', 'resque-redis', sidekiq-redis', 's3']
|
91
104
|
|
92
105
|
# Add one or more custom checks that return a blank string if ok, or an error message if there is an error
|
93
106
|
config.add_custom_check do
|
@@ -129,7 +142,7 @@ The hash contains two keys:
|
|
129
142
|
* healthy - true if requested checks pass (boolean)
|
130
143
|
* message - text message ("success" or error message)
|
131
144
|
|
132
|
-
The following commands
|
145
|
+
The following commands
|
133
146
|
|
134
147
|
curl -v localhost:3000/health_check.json
|
135
148
|
curl -v localhost:3000/health_check/email.json
|
@@ -189,9 +202,9 @@ Likewise you will probably want to exclude health_check from monitoring systems
|
|
189
202
|
=== Automated testing and other checks
|
190
203
|
|
191
204
|
* {<img src="https://badge.fury.io/rb/health_check.png" alt="Gem Version" />}[http://badge.fury.io/rb/health_check] - Latest Gem
|
192
|
-
* {<img src="https://travis-ci.org/ianheggie/health_check.png">}[https://travis-ci.org/ianheggie/health_check] - Travis CI
|
205
|
+
* {<img src="https://travis-ci.org/ianheggie/health_check.png">}[https://travis-ci.org/ianheggie/health_check] - Travis CI
|
193
206
|
* {<img src="https://codeclimate.com/github/ianheggie/health_check.png" />}[https://codeclimate.com/github/ianheggie/health_check] - Code quality
|
194
|
-
* {<img src="https://gemnasium.com/ianheggie/health_check.png">}[https://gemnasium.com/ianheggie/health_check] - Gem dependencies
|
207
|
+
* {<img src="https://gemnasium.com/ianheggie/health_check.png">}[https://gemnasium.com/ianheggie/health_check] - Gem dependencies
|
195
208
|
|
196
209
|
=== Manual testing
|
197
210
|
|
@@ -242,4 +255,3 @@ Thanks go to the various people who have given feedback and suggestions via the
|
|
242
255
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
243
256
|
4. Push to the branch (`git push origin my-new-feature`)
|
244
257
|
5. Create new Pull Request (Code with BDD tests are favoured)
|
245
|
-
|
data/lib/health_check.rb
CHANGED
@@ -23,12 +23,16 @@ module HealthCheck
|
|
23
23
|
mattr_accessor :http_status_for_error_object
|
24
24
|
self.http_status_for_error_object = 500
|
25
25
|
|
26
|
+
# s3 buckets
|
27
|
+
mattr_accessor :buckets
|
28
|
+
self.buckets = {}
|
29
|
+
|
26
30
|
# Array of custom check blocks
|
27
31
|
mattr_accessor :custom_checks
|
28
32
|
mattr_accessor :full_checks
|
29
33
|
mattr_accessor :standard_checks
|
30
34
|
self.custom_checks = [ ]
|
31
|
-
self.full_checks = ['database', 'migrations', 'custom', 'email', 'cache']
|
35
|
+
self.full_checks = ['database', 'migrations', 'custom', 'email', 'cache', 'redis-if-present', 'sidekiq-redis-if-present', 'resque-redis-if-present', 's3-if-present']
|
32
36
|
self.standard_checks = [ 'database', 'migrations', 'custom', 'emailconf' ]
|
33
37
|
|
34
38
|
def self.add_custom_check(&block)
|
@@ -41,7 +45,12 @@ module HealthCheck
|
|
41
45
|
|
42
46
|
end
|
43
47
|
|
44
|
-
require
|
48
|
+
require 'health_check/version'
|
49
|
+
require 'health_check/base_health_check'
|
50
|
+
require 'health_check/resque_health_check'
|
51
|
+
require 'health_check/s3_health_check'
|
52
|
+
require 'health_check/redis_health_check'
|
53
|
+
require 'health_check/sidekiq_health_check'
|
45
54
|
require 'health_check/utils'
|
46
55
|
require 'health_check/health_check_controller'
|
47
56
|
require 'health_check/health_check_routes'
|
@@ -14,11 +14,12 @@ module HealthCheck
|
|
14
14
|
errors = e.message.blank? ? e.class.to_s : e.message.to_s
|
15
15
|
end
|
16
16
|
if errors.blank?
|
17
|
+
response.headers['Last-Modified'] = Time.now.httpdate
|
17
18
|
obj = { :healthy => true, :message => HealthCheck.success }
|
18
19
|
respond_to do |format|
|
19
20
|
format.html { render :text => HealthCheck.success, :content_type => 'text/plain' }
|
20
|
-
format.json { render :
|
21
|
-
format.xml { render :xml => obj
|
21
|
+
format.json { render :json => obj }
|
22
|
+
format.xml { render :xml => obj }
|
22
23
|
format.any { render :text => HealthCheck.success, :content_type => 'text/plain' }
|
23
24
|
end
|
24
25
|
else
|
@@ -26,8 +27,8 @@ module HealthCheck
|
|
26
27
|
obj = { :healthy => false, :message => msg }
|
27
28
|
respond_to do |format|
|
28
29
|
format.html { render :text => msg, :status => HealthCheck.http_status_for_error_text, :content_type => 'text/plain' }
|
29
|
-
format.json { render :
|
30
|
-
format.xml { render :xml => obj
|
30
|
+
format.json { render :json => obj, :status => HealthCheck.http_status_for_error_object}
|
31
|
+
format.xml { render :xml => obj, :status => HealthCheck.http_status_for_error_object }
|
31
32
|
format.any { render :text => msg, :status => HealthCheck.http_status_for_error_text, :content_type => 'text/plain' }
|
32
33
|
end
|
33
34
|
# Log a single line as some uptime checkers only record that it failed, not the text returned
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module HealthCheck
|
2
|
+
class RedisHealthCheck
|
3
|
+
extend BaseHealthCheck
|
4
|
+
|
5
|
+
def self.check
|
6
|
+
unless defined?(::Redis)
|
7
|
+
raise "Wrong configuration. Missing 'redis' gem"
|
8
|
+
end
|
9
|
+
res = ::Redis.new.ping
|
10
|
+
res == 'PONG' ? '' : "Redis.ping returned #{res.inspect} instead of PONG"
|
11
|
+
rescue Exception => e
|
12
|
+
create_error 'redis', e.message
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module HealthCheck
|
2
|
+
class ResqueHealthCheck
|
3
|
+
extend BaseHealthCheck
|
4
|
+
|
5
|
+
def self.check
|
6
|
+
unless defined?(::Resque)
|
7
|
+
raise "Wrong configuration. Missing 'resque' gem"
|
8
|
+
end
|
9
|
+
res = ::Resque.redis.ping
|
10
|
+
res == 'PONG' ? '' : "Resque.redis.ping returned #{res.inspect} instead of PONG"
|
11
|
+
rescue Exception => e
|
12
|
+
create_error 'resque-redis', e.message
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
module HealthCheck
|
2
|
+
class S3HealthCheck
|
3
|
+
extend BaseHealthCheck
|
4
|
+
|
5
|
+
class << self
|
6
|
+
def check
|
7
|
+
unless defined?(::Aws)
|
8
|
+
raise "Wrong configuration. Missing 'aws-sdk' gem"
|
9
|
+
end
|
10
|
+
return create_error 's3', 'Could not connect to aws' if aws_s3_client.nil?
|
11
|
+
HealthCheck.buckets.each do |bucket_name, permissions|
|
12
|
+
if permissions.nil? # backward compatible
|
13
|
+
permissions = [:R, :W, :D]
|
14
|
+
end
|
15
|
+
permissions.each do |permision|
|
16
|
+
begin
|
17
|
+
send(permision, bucket_name)
|
18
|
+
rescue Exception => e
|
19
|
+
raise "bucket:#{bucket_name}, permission:#{permision} - #{e.message}"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
''
|
24
|
+
rescue Exception => e
|
25
|
+
create_error 's3', e.message
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def configure_client
|
31
|
+
return unless defined?(Rails)
|
32
|
+
|
33
|
+
aws_configuration = {
|
34
|
+
region: Rails.application.secrets.aws_default_region,
|
35
|
+
credentials: ::Aws::Credentials.new(
|
36
|
+
Rails.application.secrets.aws_access_key_id,
|
37
|
+
Rails.application.secrets.aws_secret_access_key
|
38
|
+
),
|
39
|
+
force_path_style: true
|
40
|
+
}
|
41
|
+
|
42
|
+
::Aws::S3::Client.new aws_configuration
|
43
|
+
end
|
44
|
+
|
45
|
+
def aws_s3_client
|
46
|
+
@aws_s3_client ||= configure_client
|
47
|
+
end
|
48
|
+
|
49
|
+
def R(bucket)
|
50
|
+
aws_s3_client.list_objects(bucket: bucket)
|
51
|
+
end
|
52
|
+
|
53
|
+
def W(bucket)
|
54
|
+
aws_s3_client.put_object(bucket: bucket,
|
55
|
+
key: "healthcheck_#{Rails.application.class.parent_name}",
|
56
|
+
body: Time.new.to_s)
|
57
|
+
end
|
58
|
+
|
59
|
+
def D(bucket)
|
60
|
+
aws_s3_client.delete_object(bucket: bucket,
|
61
|
+
key: "healthcheck_#{Rails.application.class.parent_name}")
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module HealthCheck
|
2
|
+
class SidekiqHealthCheck
|
3
|
+
extend BaseHealthCheck
|
4
|
+
|
5
|
+
def self.check
|
6
|
+
unless defined?(::Sidekiq)
|
7
|
+
raise "Wrong configuration. Missing 'sidekiq' gem"
|
8
|
+
end
|
9
|
+
::Sidekiq.redis do |r|
|
10
|
+
res = r.ping
|
11
|
+
res == 'PONG' ? '' : "Sidekiq.redis.ping returned #{res.inspect} instead of PONG"
|
12
|
+
end
|
13
|
+
rescue Exception => e
|
14
|
+
create_error 'sidekiq-redis', e.message
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/health_check/utils.rb
CHANGED
@@ -17,7 +17,6 @@ module HealthCheck
|
|
17
17
|
|
18
18
|
cattr_accessor :default_smtp_settings
|
19
19
|
|
20
|
-
|
21
20
|
def self.process_checks(checks)
|
22
21
|
errors = ''
|
23
22
|
checks.split('_').each do |check|
|
@@ -47,6 +46,22 @@ module HealthCheck
|
|
47
46
|
end
|
48
47
|
when 'cache'
|
49
48
|
errors << HealthCheck::Utils.check_cache
|
49
|
+
when 'resque-redis-if-present'
|
50
|
+
errors << HealthCheck::ResqueHealthCheck.check if defined?(::Resque)
|
51
|
+
when 'sidekiq-redis-if-present'
|
52
|
+
errors << HealthCheck::SidekiqHealthCheck.check if defined?(::Sidekiq)
|
53
|
+
when 'redis-if-present'
|
54
|
+
errors << HealthCheck::RedisHealthCheck.check if defined?(::Redis)
|
55
|
+
when 's3-if-present'
|
56
|
+
errors << HealthCheck::S3HealthCheck.check if defined?(::Aws)
|
57
|
+
when 'resque-redis'
|
58
|
+
errors << HealthCheck::ResqueHealthCheck.check
|
59
|
+
when 'sidekiq-redis'
|
60
|
+
errors << HealthCheck::SidekiqHealthCheck.check
|
61
|
+
when 'redis'
|
62
|
+
errors << HealthCheck::RedisHealthCheck.check
|
63
|
+
when 's3'
|
64
|
+
errors << HealthCheck::S3HealthCheck.check
|
50
65
|
when "standard"
|
51
66
|
errors << HealthCheck::Utils.process_checks(HealthCheck.standard_checks.join('_'))
|
52
67
|
when "custom"
|
@@ -60,9 +75,10 @@ module HealthCheck
|
|
60
75
|
end
|
61
76
|
end
|
62
77
|
return errors
|
78
|
+
rescue => e
|
79
|
+
return e.message
|
63
80
|
end
|
64
81
|
|
65
|
-
|
66
82
|
def self.db_migrate_path
|
67
83
|
# Lazy initialisation so Rails.root will be defined
|
68
84
|
@@db_migrate_path ||= File.join(Rails.root, 'db', 'migrate')
|
@@ -100,7 +116,6 @@ module HealthCheck
|
|
100
116
|
end
|
101
117
|
end
|
102
118
|
|
103
|
-
|
104
119
|
def self.check_sendmail(settings)
|
105
120
|
File.executable?(settings[:location]) ? '' : 'no sendmail executable found. '
|
106
121
|
end
|
data/lib/health_check/version.rb
CHANGED
data/test/rails_4.0.gemfile
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
source 'https://rubygems.org'
|
4
4
|
|
5
|
-
ruby '1.9.3'
|
5
|
+
ruby RUBY_VERSION < '1.9.3' ? '1.9.3' : RUBY_VERSION
|
6
6
|
|
7
7
|
gem 'rails', "~> 4.0.0"
|
8
8
|
gem 'rake', '>= 0.8.3'
|
@@ -16,8 +16,18 @@ group :development, :test do
|
|
16
16
|
gem 'sqlite3', "~> 1.3.7"
|
17
17
|
end
|
18
18
|
gem 'shoulda'
|
19
|
+
|
20
|
+
# redis based checks
|
21
|
+
gem 'sidekiq', :require => !ENV['SIDEKIQ'].nil?
|
22
|
+
gem 'redis', :require => !ENV['REDIS_URL'].nil?
|
23
|
+
gem 'resque', :require => !ENV['RESQUE'].nil?
|
24
|
+
# s3 check
|
25
|
+
gem 'aws-sdk', :require => !ENV['AWS_ACCESS_KEY_ID'].nil?
|
19
26
|
end
|
20
27
|
|
21
28
|
# Initial Gemfile has therubyracer commented out
|
22
29
|
gem 'therubyrhino', :platform => :jruby # REQUIRED
|
23
30
|
gem 'therubyracer', :platform => :ruby # REQUIRED
|
31
|
+
# mime-types 2.0 requires Ruby version >= 1.9.2
|
32
|
+
# mime-types 3.0 requires Ruby version >= 2.0
|
33
|
+
gem 'mime-types', RUBY_VERSION < '1.9.2' ? '< 2.0' : (defined?(JRUBY_VERSION) || RUBY_VERSION < '2.0' ? '< 3.0' : '>= 3.0') # REQUIRED
|
data/test/rails_4.1.gemfile
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
source 'https://rubygems.org'
|
4
4
|
|
5
|
-
ruby '1.9.3'
|
5
|
+
ruby RUBY_VERSION < '1.9.3' ? '1.9.3' : RUBY_VERSION
|
6
6
|
|
7
7
|
gem 'rails', "~> 4.1.0"
|
8
8
|
gem 'rake', '>= 0.8.3'
|
@@ -16,8 +16,18 @@ group :development, :test do
|
|
16
16
|
gem 'sqlite3', "~> 1.3.7"
|
17
17
|
end
|
18
18
|
gem 'shoulda'
|
19
|
+
|
20
|
+
# redis based checks
|
21
|
+
gem 'sidekiq', :require => !ENV['SIDEKIQ'].nil?
|
22
|
+
gem 'redis', :require => !ENV['REDIS_URL'].nil?
|
23
|
+
gem 'resque', :require => !ENV['RESQUE'].nil?
|
24
|
+
# s3 check
|
25
|
+
gem 'aws-sdk', :require => !ENV['AWS_ACCESS_KEY_ID'].nil?
|
19
26
|
end
|
20
27
|
|
21
28
|
# Initial Gemfile has therubyracer commented out
|
22
29
|
gem 'therubyrhino', :platform => :jruby # REQUIRED
|
23
30
|
gem 'therubyracer', :platform => :ruby # REQUIRED
|
31
|
+
# mime-types 2.0 requires Ruby version >= 1.9.2
|
32
|
+
# mime-types 3.0 requires Ruby version >= 2.0
|
33
|
+
gem 'mime-types', RUBY_VERSION < '1.9.2' ? '< 2.0' : (defined?(JRUBY_VERSION) || RUBY_VERSION < '2.0' ? '< 3.0' : '>= 3.0') # REQUIRED
|
data/test/rails_4.2.gemfile
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
source 'https://rubygems.org'
|
4
4
|
|
5
|
-
ruby '1.9.3'
|
5
|
+
ruby RUBY_VERSION < '1.9.3' ? '1.9.3' : RUBY_VERSION
|
6
6
|
|
7
7
|
gem 'rails', "~> 4.2.0"
|
8
8
|
gem 'rake', '>= 0.8.3'
|
@@ -16,4 +16,15 @@ group :development, :test do
|
|
16
16
|
gem 'sqlite3', "~> 1.3.7"
|
17
17
|
end
|
18
18
|
gem 'shoulda'
|
19
|
+
|
20
|
+
# redis based checks
|
21
|
+
gem 'sidekiq', :require => !ENV['SIDEKIQ'].nil?
|
22
|
+
gem 'redis', :require => !ENV['REDIS_URL'].nil?
|
23
|
+
gem 'resque', :require => !ENV['RESQUE'].nil?
|
24
|
+
# s3 check
|
25
|
+
gem 'aws-sdk', :require => !ENV['AWS_ACCESS_KEY_ID'].nil?
|
19
26
|
end
|
27
|
+
|
28
|
+
# mime-types 2.0 requires Ruby version >= 1.9.2
|
29
|
+
# mime-types 3.0 requires Ruby version >= 2.0
|
30
|
+
gem 'mime-types', RUBY_VERSION < '1.9.2' ? '< 2.0' : (defined?(JRUBY_VERSION) || RUBY_VERSION < '2.0' ? '< 3.0' : '>= 3.0') # REQUIRED
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# Gemfile for health_test testing
|
2
|
+
|
3
|
+
source 'https://rubygems.org'
|
4
|
+
|
5
|
+
ruby RUBY_VERSION < '2.2.2' ? '2.2.2' : RUBY_VERSION
|
6
|
+
|
7
|
+
gem 'rails', '~> 5.0.0'
|
8
|
+
gem 'rake', '>= 0.8.7'
|
9
|
+
|
10
|
+
group :development, :test do
|
11
|
+
if defined?(JRUBY_VERSION)
|
12
|
+
gem 'jruby-openssl'
|
13
|
+
gem 'activerecord-jdbcsqlite3-adapter'
|
14
|
+
else
|
15
|
+
gem 'sqlite3', "~> 1.3.7"
|
16
|
+
end
|
17
|
+
gem 'shoulda'
|
18
|
+
|
19
|
+
# redis based checks
|
20
|
+
gem 'sidekiq', :require => !ENV['SIDEKIQ'].nil?
|
21
|
+
gem 'redis', :require => !ENV['REDIS_URL'].nil?
|
22
|
+
gem 'resque', :require => !ENV['RESQUE'].nil?
|
23
|
+
# s3 check
|
24
|
+
gem 'aws-sdk', :require => !ENV['AWS_ACCESS_KEY_ID'].nil?
|
25
|
+
end
|
26
|
+
|
data/test/rails_edge.gemfile
CHANGED
@@ -4,7 +4,7 @@ source 'https://rubygems.org'
|
|
4
4
|
|
5
5
|
# Bundle edge Rails instead:
|
6
6
|
|
7
|
-
ruby '
|
7
|
+
ruby RUBY_VERSION < '2.2.2' ? '2.2.2' : RUBY_VERSION
|
8
8
|
|
9
9
|
gem 'rails'
|
10
10
|
gem 'rake'
|
@@ -18,6 +18,13 @@ group :development, :test do
|
|
18
18
|
gem 'sqlite3'
|
19
19
|
end
|
20
20
|
gem 'shoulda'
|
21
|
+
|
22
|
+
# redis based checks
|
23
|
+
gem 'sidekiq', :require => !ENV['SIDEKIQ'].nil?
|
24
|
+
gem 'redis', :require => !ENV['REDIS_URL'].nil?
|
25
|
+
gem 'resque', :require => !ENV['RESQUE'].nil?
|
26
|
+
# s3 check
|
27
|
+
gem 'aws-sdk', :require => !ENV['AWS_ACCESS_KEY_ID'].nil?
|
21
28
|
end
|
22
29
|
|
23
30
|
# Initial Gemfile has therubyracer commented out
|
data/test/setup_railsapp
CHANGED
@@ -59,8 +59,10 @@ fi
|
|
59
59
|
$rehash
|
60
60
|
|
61
61
|
rails="$base_dir/test/bin/rails"
|
62
|
+
rake="$base_dir/test/bin/rake"
|
62
63
|
|
63
64
|
echo Checking $rails is present ...
|
65
|
+
[ -f $rails -a -f $rake ] || bundle exec rake rails:update:bin || echo '(ignored rake rails:update:bin exit status)'
|
64
66
|
[ -f $rails ] || bundle binstub railties || echo '(ignored bundle exit status)'
|
65
67
|
[ -f $rails ] || bundle binstub rails || echo '(ignored bundle exit status)'
|
66
68
|
if [ ! -f $rails ]; then
|
@@ -68,8 +70,6 @@ if [ ! -f $rails ]; then
|
|
68
70
|
exit 2
|
69
71
|
fi
|
70
72
|
|
71
|
-
rake="$base_dir/test/bin/rake"
|
72
|
-
|
73
73
|
if [ ! -f $rake ]; then
|
74
74
|
echo "Running bundle --binstub rake ..."
|
75
75
|
if ! bundle --binstub rake || [ ! -f $rake ]; then
|
@@ -111,7 +111,7 @@ case "$actual_rails_version" in
|
|
111
111
|
*' '[12].*)
|
112
112
|
$rails railsapp -d $db
|
113
113
|
;;
|
114
|
-
*' '[
|
114
|
+
*' '[345].*)
|
115
115
|
case "$BUNDLE_GEMFILE" in
|
116
116
|
*rails_edge.gemfile)
|
117
117
|
$rails new railsapp -d $db --edge
|
@@ -187,15 +187,16 @@ then
|
|
187
187
|
$rehash
|
188
188
|
echo "Using binstubs in $railsapp/bin for rails and rake commands"
|
189
189
|
rails="$railsapp/bin/rails"
|
190
|
+
rake="$railsapp/bin/rake"
|
190
191
|
|
191
192
|
echo Checking $rails is present ...
|
193
|
+
[ -f $rails -a -f $rake ] || bundle exec rake rails:update:bin || echo '(ignored rake rails:update:bin exit status)'
|
192
194
|
[ -f $rails ] || bundle binstub railties || echo '(ignored bundle exit status)'
|
193
195
|
[ -f $rails ] || bundle binstub rails || echo '(ignored bundle exit status)'
|
194
196
|
if [ ! -f $rails ]; then
|
195
197
|
echo "Test aborted (unable to create $rails)"
|
196
198
|
exit 2
|
197
199
|
fi
|
198
|
-
rake="$railsapp/bin/rake"
|
199
200
|
|
200
201
|
echo Checking $rake is present ...
|
201
202
|
[ -f $rake ] || bundle binstub rake || echo '(ignored bundle exit status)'
|
data/test/test_with_railsapp
CHANGED
@@ -9,6 +9,7 @@ trap 'err_report $LINENO' ERR
|
|
9
9
|
|
10
10
|
# Any failure causes exit
|
11
11
|
set -e
|
12
|
+
export DISABLE_SPRING=1
|
12
13
|
|
13
14
|
cleanup_db()
|
14
15
|
{
|
@@ -78,6 +79,7 @@ start_server()
|
|
78
79
|
bundle_prefix='bundle exec'
|
79
80
|
fi
|
80
81
|
server_arg=${RAILS_SERVER:-webrick}
|
82
|
+
echo "start_server called using: `env | egrep '^RAILS|^RACK|^PATH='` $bundle_prefix $server_arg"
|
81
83
|
case "$server_arg" in
|
82
84
|
puma)
|
83
85
|
$bundle_prefix puma -b tcp://127.0.0.1:$port &
|
@@ -103,6 +105,7 @@ start_server()
|
|
103
105
|
;;
|
104
106
|
esac
|
105
107
|
server_pid=$!
|
108
|
+
echo Server pid: $server_pid
|
106
109
|
sleep 3
|
107
110
|
echo
|
108
111
|
echo 'Checking server is up ...'
|
@@ -193,11 +196,12 @@ common_tests()
|
|
193
196
|
test_no=`expr 1 + $test_no`
|
194
197
|
if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
|
195
198
|
echo "${test_no}: TESTING can get a static file ..."
|
196
|
-
case "$RAILS_ENV=`egrep
|
197
|
-
production*static*)
|
199
|
+
case "$RAILS_ENV=`egrep '^\s*config.serve_static_[asetfil]* *= *false' config/environments/${RAILS_ENV}.rb`" in
|
200
|
+
production*static*false*)
|
198
201
|
echo " SKIPPED (disabled in production)"
|
199
202
|
;;
|
200
203
|
*)
|
204
|
+
grep serve_static_files config/environments/${RAILS_ENV}.rb config/[a-z]*.rb || echo no serve_static_files entry
|
201
205
|
$testurl ${host}/static.txt 200 text/plain STATIC-FILE
|
202
206
|
;;
|
203
207
|
esac
|
@@ -410,6 +414,9 @@ common_tests()
|
|
410
414
|
# required for rails 4.1+ in production mode
|
411
415
|
export SECRET_KEY_BASE=cf2f49c38a3fe67416ddf680f4f3187c0fce7dd1b9b117b34d195df75b274e08a04877e23803b2fdf1aa9a655269d94bc4888aa325cf7e721cc47368cfe56a80
|
412
416
|
|
417
|
+
# required for rails 5 to server static files
|
418
|
+
export RAILS_SERVE_STATIC_FILES=on
|
419
|
+
|
413
420
|
case "$run_test" in
|
414
421
|
???)
|
415
422
|
;;
|
data/test/testurl
CHANGED
@@ -52,7 +52,7 @@ if ARGV[3] and ARGV[3] != ''
|
|
52
52
|
if page_content.to_s.include? ARGV[3]
|
53
53
|
puts "PASS (found #{ARGV[3]})"
|
54
54
|
else
|
55
|
-
puts "FAIL (
|
55
|
+
puts "FAIL (expected to find #{ARGV[3]}) - page contents:" , page_content.to_s, 'END-OF-CONTENTS'
|
56
56
|
exit 3
|
57
57
|
end
|
58
58
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: health_check
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-07-
|
12
|
+
date: 2016-07-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -96,8 +96,13 @@ files:
|
|
96
96
|
- health_check.gemspec
|
97
97
|
- init.rb
|
98
98
|
- lib/health_check.rb
|
99
|
+
- lib/health_check/base_health_check.rb
|
99
100
|
- lib/health_check/health_check_controller.rb
|
100
101
|
- lib/health_check/health_check_routes.rb
|
102
|
+
- lib/health_check/redis_health_check.rb
|
103
|
+
- lib/health_check/resque_health_check.rb
|
104
|
+
- lib/health_check/s3_health_check.rb
|
105
|
+
- lib/health_check/sidekiq_health_check.rb
|
101
106
|
- lib/health_check/utils.rb
|
102
107
|
- lib/health_check/version.rb
|
103
108
|
- test/fake_smtp_server
|
@@ -110,6 +115,7 @@ files:
|
|
110
115
|
- test/rails_4.0.gemfile
|
111
116
|
- test/rails_4.1.gemfile
|
112
117
|
- test/rails_4.2.gemfile
|
118
|
+
- test/rails_5.0.gemfile
|
113
119
|
- test/rails_edge.gemfile
|
114
120
|
- test/setup_railsapp
|
115
121
|
- test/test_helper.rb
|
@@ -153,6 +159,7 @@ test_files:
|
|
153
159
|
- test/rails_4.0.gemfile
|
154
160
|
- test/rails_4.1.gemfile
|
155
161
|
- test/rails_4.2.gemfile
|
162
|
+
- test/rails_5.0.gemfile
|
156
163
|
- test/rails_edge.gemfile
|
157
164
|
- test/setup_railsapp
|
158
165
|
- test/test_helper.rb
|