health_check 2.5.0 → 2.6.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,5 +1,7 @@
1
1
  = Change Log =
2
2
 
3
+ * 2.6.0
4
+ * Add named custom checks
3
5
  * 2.5.0
4
6
  * Added whitelist for IP# (Thanks Fernando Alvarez)
5
7
  * reworked whitelist PR
@@ -114,6 +114,13 @@ To change the configuration of health_check, create a file `config/initializers/
114
114
  CustomHealthCheck.perform_check # any code that returns blank on success and non blank string upon failure
115
115
  end
116
116
 
117
+ # Add another custom check with a name, so you can call just specific custom checks. This can also be run using
118
+ # the standard 'custom' check.
119
+ # You can define multiple tests under the same name - they will be run one after the other.
120
+ config.add_custom_check('sometest') do
121
+ CustomHealthCheck.perform_another_check # any code that returns blank on success and non blank string upon failure
122
+ end
123
+
117
124
  # max-age of response in seconds
118
125
  # cache-control is public when max_age > 1 and basic_auth_username is not set
119
126
  # You can force private without authentication for longer max_age by
@@ -53,7 +53,7 @@ module HealthCheck
53
53
  mattr_accessor :custom_checks
54
54
  mattr_accessor :full_checks
55
55
  mattr_accessor :standard_checks
56
- self.custom_checks = [ ]
56
+ self.custom_checks = { }
57
57
  self.full_checks = ['database', 'migrations', 'custom', 'email', 'cache', 'redis-if-present', 'sidekiq-redis-if-present', 'resque-redis-if-present', 's3-if-present']
58
58
  self.standard_checks = [ 'database', 'migrations', 'custom', 'emailconf' ]
59
59
 
@@ -63,8 +63,9 @@ module HealthCheck
63
63
 
64
64
  mattr_accessor :installed_as_middleware
65
65
 
66
- def self.add_custom_check(&block)
67
- custom_checks << block
66
+ def self.add_custom_check(name = 'custom', &block)
67
+ custom_checks[name] ||= [ ]
68
+ custom_checks[name] << block
68
69
  end
69
70
 
70
71
  def self.setup
@@ -68,13 +68,21 @@ module HealthCheck
68
68
  when "middleware"
69
69
  errors << "Health check not called from middleware - probably not installed as middleware." unless called_from_middleware
70
70
  when "custom"
71
- HealthCheck.custom_checks.each do |custom_check|
72
- errors << custom_check.call(self)
71
+ HealthCheck.custom_checks.each do |name, list|
72
+ list.each do |custom_check|
73
+ errors << custom_check.call(self)
74
+ end
73
75
  end
74
76
  when "all", "full"
75
77
  errors << HealthCheck::Utils.process_checks(HealthCheck.full_checks, called_from_middleware)
76
78
  else
77
- return "invalid argument to health_test."
79
+ if HealthCheck.custom_checks.include? check
80
+ HealthCheck.custom_checks[check].each do |custom_check|
81
+ errors << custom_check.call(self)
82
+ end
83
+ else
84
+ return "invalid argument to health_test."
85
+ end
78
86
  end
79
87
  end
80
88
  return errors
@@ -1,3 +1,3 @@
1
1
  module HealthCheck
2
- VERSION = "2.5.0"
2
+ VERSION = "2.6.0"
3
3
  end
@@ -175,6 +175,11 @@ HealthCheck.setup do |config|
175
175
  config.add_custom_check do
176
176
  File.exists?("$custom_file") ? '' : '$custom_file is missing!'
177
177
  end
178
+
179
+ config.add_custom_check('pass') do
180
+ ''
181
+ end
182
+
178
183
  end
179
184
  !
180
185
 
@@ -402,6 +402,13 @@ common_tests()
402
402
  echo
403
403
  fi
404
404
 
405
+ test_no=`expr 1 + $test_no`
406
+ if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
407
+ echo "${test_no}: TESTING ${route_prefix}/pass should pass ..."
408
+ $testurl ${host}/${route_prefix}/pass 200 text/plain $success
409
+ echo
410
+ fi
411
+
405
412
  test_no=`expr 1 + $test_no`
406
413
  if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
407
414
  echo "${test_no}: TESTING ${route_prefix}/custom should pass ..."
@@ -440,6 +447,12 @@ common_tests()
440
447
  echo
441
448
  fi
442
449
 
450
+ if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
451
+ echo "${test_no}: TESTING ${route_prefix}/pass should pass even if other custom test returns string ..."
452
+ $testurl ${host}/${route_prefix}/pass 200 text/plain $success
453
+ echo
454
+ fi
455
+
443
456
  test_no=`expr 1 + $test_no`
444
457
  if [ -z "$run_test" ] || [ $test_no == "$run_test" ]; then
445
458
  echo "${test_no}: TESTING ${route_prefix} (all) should fail when custom check fails ..."
metadata CHANGED
@@ -1,72 +1,81 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: health_check
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.0
4
+ version: 2.6.0
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Ian Heggie
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2016-12-03 00:00:00.000000000 Z
12
+ date: 2016-12-07 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: rails
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
- - - ">="
19
+ - - ! '>='
18
20
  - !ruby/object:Gem::Version
19
21
  version: '4.0'
20
22
  type: :runtime
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
- - - ">="
27
+ - - ! '>='
25
28
  - !ruby/object:Gem::Version
26
29
  version: '4.0'
27
30
  - !ruby/object:Gem::Dependency
28
31
  name: rake
29
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
30
34
  requirements:
31
- - - ">="
35
+ - - ! '>='
32
36
  - !ruby/object:Gem::Version
33
37
  version: 0.8.3
34
38
  type: :development
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
- - - ">="
43
+ - - ! '>='
39
44
  - !ruby/object:Gem::Version
40
45
  version: 0.8.3
41
46
  - !ruby/object:Gem::Dependency
42
47
  name: shoulda
43
48
  requirement: !ruby/object:Gem::Requirement
49
+ none: false
44
50
  requirements:
45
- - - "~>"
51
+ - - ~>
46
52
  - !ruby/object:Gem::Version
47
53
  version: 2.11.0
48
54
  type: :development
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
51
58
  requirements:
52
- - - "~>"
59
+ - - ~>
53
60
  - !ruby/object:Gem::Version
54
61
  version: 2.11.0
55
62
  - !ruby/object:Gem::Dependency
56
63
  name: bundler
57
64
  requirement: !ruby/object:Gem::Requirement
65
+ none: false
58
66
  requirements:
59
- - - "~>"
67
+ - - ~>
60
68
  - !ruby/object:Gem::Version
61
69
  version: '1.2'
62
70
  type: :development
63
71
  prerelease: false
64
72
  version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
65
74
  requirements:
66
- - - "~>"
75
+ - - ~>
67
76
  - !ruby/object:Gem::Version
68
77
  version: '1.2'
69
- description: " \tSimple health check of Rails app for uptime monitoring with Pingdom,
78
+ description: ! " \tSimple health check of Rails app for uptime monitoring with Pingdom,
70
79
  NewRelic, EngineYard or uptime.openacs.org etc.\n"
71
80
  email:
72
81
  - ian@heggie.biz
@@ -75,9 +84,9 @@ extensions: []
75
84
  extra_rdoc_files:
76
85
  - README.rdoc
77
86
  files:
78
- - ".document"
79
- - ".gitignore"
80
- - ".travis.yml"
87
+ - .document
88
+ - .gitignore
89
+ - .travis.yml
81
90
  - CHANGELOG
82
91
  - Gemfile
83
92
  - MIT-LICENSE
@@ -114,26 +123,27 @@ files:
114
123
  - test/testurl
115
124
  homepage: https://github.com/ianheggie/health_check
116
125
  licenses: []
117
- metadata: {}
118
126
  post_install_message:
119
127
  rdoc_options: []
120
128
  require_paths:
121
129
  - lib
122
130
  required_ruby_version: !ruby/object:Gem::Requirement
131
+ none: false
123
132
  requirements:
124
- - - ">="
133
+ - - ! '>='
125
134
  - !ruby/object:Gem::Version
126
135
  version: 1.9.3
127
136
  required_rubygems_version: !ruby/object:Gem::Requirement
137
+ none: false
128
138
  requirements:
129
- - - ">="
139
+ - - ! '>='
130
140
  - !ruby/object:Gem::Version
131
141
  version: '0'
132
142
  requirements: []
133
143
  rubyforge_project:
134
- rubygems_version: 2.5.1
144
+ rubygems_version: 1.8.25
135
145
  signing_key:
136
- specification_version: 4
146
+ specification_version: 3
137
147
  summary: Simple health check of Rails app for uptime monitoring with Pingdom, NewRelic,
138
148
  EngineYard or uptime.openacs.org etc.
139
149
  test_files:
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 4b5a934dfee4618efc3d217163112b251e926879
4
- data.tar.gz: 811fdba5dd439ef0016ca94c8c2b0b6dbac19a99
5
- SHA512:
6
- metadata.gz: fd09549905a225cc3c25a02f295335dcb013cb565c52095d4b87e1fb4e74552d4231637d7a4e9b7698c28f896103cf529cd1aefbbf1089dfb1b161c650ca11da
7
- data.tar.gz: 44fc64d17c2722c5bd3841d65dabf2bc5f55b0a61b01a862484ea79f4b64ebe29d4300667b5c6f572eb50f5c90c8be59bcb783517721c2de18e3bbdc54929f42