health_check 3.0.0 → 3.1.0

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
- SHA1:
3
- metadata.gz: 812ae12a10cfd6d24437f79dac7bd3b56ba46b01
4
- data.tar.gz: a9df5e7810a0a165c56f69f6bf837ace4e2280cd
2
+ SHA256:
3
+ metadata.gz: 5a8f9b5697e674eadaf79c49e68c55ef01c794a1fdb07c094026000aaa140296
4
+ data.tar.gz: 7598cfd30e1896ced703f44eee24a9c5f10110e9874c7461d9a7b014a704a686
5
5
  SHA512:
6
- metadata.gz: 0da389e2581efa8883b27cea5dd76aa789caae942d11abccddd64455b7a03add304869b9e418e61f1a20206f6ed86eea4fa52ad74162c1e885724d0d984ba1d1
7
- data.tar.gz: 4a726df067df79fe849dadf29e23d5794205de76c3b3fcd18756e354b711c650cc73c6d10a6121ac11adedf69aeaaacfe70c518377d3687ba4bfd6aff98cfec7
6
+ metadata.gz: 710941df9c976069d0a81cdd0f5e739bf82dd7b836c17d03c827b374988b729aa7f165101e87d1eef40a83312377338d8696a0e9b3a7961259babaee6e2a4925
7
+ data.tar.gz: 32b2cd9adde99918e95b9734a7ae8e096c7300c53c7385541f0e8fb31052ff3739d39858271f3deea316aed2925b2c3e5427bbc378ef8403392fa8a414bac05a
data/.gitignore CHANGED
@@ -24,6 +24,8 @@ test/bin/
24
24
  railsapps/
25
25
  test/*.gemfile.lock
26
26
  ,*
27
+ .vagrant
28
+ ubuntu*console.log
27
29
 
28
30
  # See: https://gist.github.com/ianheggie/9327010
29
31
  # for Global git ignore for OS/IDE/temp/backup files
data/.travis.yml CHANGED
@@ -1,4 +1,7 @@
1
- sudo: false
1
+ dest: xenial
2
+ os: linux
3
+ # Released April 2018, Support ended: April 2023
4
+ # ruby 2.4.9, 2.5.3, 2.5.7, 2.6.5 (default) and 2.7.0 pre-installed on travis
2
5
  addons:
3
6
  apt:
4
7
  packages:
@@ -23,9 +26,39 @@ bundler_args: "--binstubs"
23
26
 
24
27
  script: ./test/test_with_railsapp
25
28
 
26
- matrix:
29
+ jobs:
27
30
  fast_finish: true
28
31
 
32
+ allow_failures:
33
+
34
+ - rvm: 3.0.1
35
+ gemfile: test/rails_6.1.gemfile
36
+ env:
37
+ - RAILS_VERSION=6.1
38
+ - MIDDLEWARE=YES
39
+
40
+ - rvm: 3.0.1
41
+ gemfile: test/rails_edge.gemfile
42
+ env:
43
+ - RAILS_VERSION=edge
44
+ - MIDDLEWARE=YES
45
+ - SMTP_STARTTLS=DISABLED
46
+
47
+ - rvm: ruby-head
48
+ gemfile: test/rails_6.1.gemfile
49
+ env:
50
+ - RAILS_VERSION=6.1
51
+ - MIDDLEWARE=YES
52
+ - SMTP_STARTTLS=DISABLED
53
+
54
+ - rvm: ruby-head
55
+ gemfile: test/rails_edge.gemfile
56
+ env:
57
+ - RAILS_VERSION=edge
58
+ - MIDDLEWARE=YES
59
+ - SMTP_STARTTLS=DISABLED
60
+
61
+
29
62
  include:
30
63
  # -------------------------------------
31
64
  # Standard
@@ -34,25 +67,40 @@ matrix:
34
67
 
35
68
  - rvm: 2.2.2
36
69
  gemfile: test/rails_5.0.gemfile
37
- env: RAILS_VERSION=5.0 MIDDLEWARE=no
70
+ env:
71
+ - RAILS_VERSION=5.0
72
+ - MIDDLEWARE=no
73
+ - RUBYGEMS_VERSION=2.7.11
74
+ - BUNDLER_VERSION=1.17.3
38
75
 
39
76
  - rvm: 2.3.6
40
77
  gemfile: test/rails_5.0.gemfile
41
- env: RAILS_VERSION=5.0 MIDDLEWARE=no
78
+ env:
79
+ - RAILS_VERSION=5.0
80
+ - MIDDLEWARE=no
42
81
 
43
82
  # rails 5.1 sometime before May 2017
44
83
 
45
84
  - rvm: 2.2.2
46
85
  gemfile: test/rails_5.1.gemfile
47
- env: RAILS_VERSION=5.1 MIDDLEWARE=no
86
+ env:
87
+ - RAILS_VERSION=5.1
88
+ - MIDDLEWARE=no
89
+ - RUBYGEMS_VERSION=2.7.11
90
+ - BUNDLER_VERSION=1.17.3
48
91
 
49
92
  - rvm: 2.3.6
50
93
  gemfile: test/rails_5.1.gemfile
51
- env: RAILS_VERSION=5.1 MIDDLEWARE=no
94
+ env:
95
+ - RAILS_VERSION=5.1
96
+ - MIDDLEWARE=no
97
+ - BUNDLER_VERSION=1.17.3
52
98
 
53
99
  - rvm: 2.4.3
54
100
  gemfile: test/rails_5.1.gemfile
55
- env: RAILS_VERSION=5.1 MIDDLEWARE=no
101
+ env:
102
+ - RAILS_VERSION=5.1
103
+ - MIDDLEWARE=no
56
104
 
57
105
  # -------------------------------------
58
106
  # Middleware
@@ -61,19 +109,110 @@ matrix:
61
109
 
62
110
  - rvm: 2.2.2
63
111
  gemfile: test/rails_5.0.gemfile
64
- env: RAILS_VERSION=5.0 MIDDLEWARE=yes
112
+ env:
113
+ - RAILS_VERSION=5.0
114
+ - MIDDLEWARE=yes
115
+ - RUBYGEMS_VERSION=2.7.11
116
+ - BUNDLER_VERSION=1.17.3
65
117
 
66
118
  - rvm: 2.3.6
67
119
  gemfile: test/rails_5.0.gemfile
68
- env: RAILS_VERSION=5.0 MIDDLEWARE=yes
120
+ env:
121
+ - RAILS_VERSION=5.0
122
+ - MIDDLEWARE=yes
69
123
 
70
124
  # rails 5.1 sometime before May 2017
71
125
 
72
126
  - rvm: 2.2.2
73
127
  gemfile: test/rails_5.1.gemfile
74
- env: RAILS_VERSION=5.1 MIDDLEWARE=yes
128
+ env:
129
+ - RAILS_VERSION=5.1
130
+ - MIDDLEWARE=yes
131
+ - RUBYGEMS_VERSION=2.7.11
132
+ - BUNDLER_VERSION=1.17.3
75
133
 
76
134
  - rvm: 2.4.3
77
135
  gemfile: test/rails_5.1.gemfile
78
- env: RAILS_VERSION=5.1 MIDDLEWARE=yes
136
+ env:
137
+ - RAILS_VERSION=5.1
138
+ - MIDDLEWARE=yes
139
+
140
+
141
+ # rails 5.2 April 2018
142
+ # -------------------------------------
143
+ # INSTALLED AS MIDDLEWARE
144
+
145
+
146
+ # rails 6.0
147
+
148
+ - rvm: 2.5.0
149
+ gemfile: test/rails_6.0.gemfile
150
+ env:
151
+ - RAILS_VERSION=6.0
152
+ - MIDDLEWARE=YES
153
+
154
+ - rvm: 2.6.7
155
+ gemfile: test/rails_6.0.gemfile
156
+ env:
157
+ - RAILS_VERSION=6.0
158
+ - MIDDLEWARE=YES
159
+
160
+ # Not testing past recommended ruby version as listed on https://www.fastruby.io/blog/ruby/rails/versions/compatibility-table.html
161
+
162
+ # --------------------------------------
163
+ - rvm: 2.5.0
164
+ gemfile: test/rails_6.1.gemfile
165
+ env:
166
+ - RAILS_VERSION=6.1
167
+ - MIDDLEWARE=YES
168
+
169
+ - rvm: 2.6.6
170
+ gemfile: test/rails_6.1.gemfile
171
+ env:
172
+ - RAILS_VERSION=6.1
173
+ - MIDDLEWARE=YES
174
+
175
+ - rvm: 2.7.3
176
+ gemfile: test/rails_6.1.gemfile
177
+ env:
178
+ - RAILS_VERSION=6.1
179
+ - MIDDLEWARE=YES
180
+
181
+ - rvm: 3.0.1
182
+ gemfile: test/rails_6.1.gemfile
183
+ env:
184
+ - RAILS_VERSION=6.1
185
+ - MIDDLEWARE=YES
186
+ - SMTP_STARTTLS=DISABLED
187
+
188
+ # ------------------
189
+ # FIXME
190
+ # ------------------
191
+
192
+ - rvm: 3.0.1
193
+ gemfile: test/rails_6.1.gemfile
194
+ env:
195
+ - RAILS_VERSION=6.1
196
+ - MIDDLEWARE=YES
197
+
198
+ - rvm: 3.0.1
199
+ gemfile: test/rails_edge.gemfile
200
+ env:
201
+ - RAILS_VERSION=edge
202
+ - MIDDLEWARE=YES
203
+ - SMTP_STARTTLS=DISABLED
204
+
205
+ - rvm: ruby-head
206
+ gemfile: test/rails_6.1.gemfile
207
+ env:
208
+ - RAILS_VERSION=6.1
209
+ - MIDDLEWARE=YES
210
+ - SMTP_STARTTLS=DISABLED
211
+
212
+ - rvm: ruby-head
213
+ gemfile: test/rails_edge.gemfile
214
+ env:
215
+ - RAILS_VERSION=edge
216
+ - MIDDLEWARE=YES
217
+ - SMTP_STARTTLS=DISABLED
79
218
 
data/CHANGELOG CHANGED
@@ -1,5 +1,26 @@
1
1
  = Change Log =
2
2
 
3
+ * 3.1.0 - 26 May 2021
4
+ * Updated README to clarify railsN branch status (they are intended to be stable, development to be a feature branch off them or master)
5
+ * Updated README with all the settings
6
+ * Updated all the branches to work with the latest travis and gem changes, as some gems needed to be locked down.
7
+ * Updated to test rails 6.0 and 6.1
8
+ * Got all travis tests passing
9
+ * Removed old, unused branches
10
+ * Merged PR Fix broken Cache-Control headers #93 from felixbuenemann
11
+ * Merged PR S3 should not depend on Rails secrets file #77 by natefaerber
12
+ * Merged PR RabbitMQ Health check #98 from rhuanbarreto
13
+ * Merged PR Use remote_ip to accept proxy-forwarded requests #102 by alessio-signorini but made it optional
14
+ * Fixed up failure setting to match previous output on error, and use it as a prefix when the error message is also output (not by default)
15
+ * Always log the error to rails log even if not including in html response
16
+ * Merged PR ensure REDIS connections are closed #88 from yld
17
+ * Merged PR more robust cache check #90 from masciugo
18
+ * Merged PR Add log_level config setting which defaults to 'info'. #97 from FloHeinle
19
+ * Merged PR get rid of old school hash rockets syntax #92 from DmytroStepaniuk
20
+ * Merged PR Converted whitelist testing to use IPAddr objects. #64 jordanyaker
21
+ * Added on_success and on_failure callbacks
22
+ * Makes sure errors are seperated by a period and a space and a period always ends the list of errors
23
+
3
24
  * 3.0.0
4
25
  * First release on rails5 branch
5
26
  * Depends on railties rather than rails so it can be used with trimmed down stacks
data/README.rdoc CHANGED
@@ -1,11 +1,19 @@
1
1
  = health_check gem
2
2
 
3
- Simple health check of Rails 5.x apps for use with Pingdom, NewRelic, EngineYard or uptime.openacs.org etc.
3
+ Simple health check of Rails 5.x and 6.x apps for use with Pingdom, NewRelic, EngineYard etc.
4
4
 
5
5
  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)
6
6
 
7
7
  Check the latest README {master}[https://github.com/ianheggie/health_check/tree/master] for other versions
8
8
 
9
+ Use gem versions for stable releases:
10
+ * ~> 3.x for Rails 5.x and 6.x (etc until there is a proven need to split off another branch),
11
+ * ~> 2.x for Rails 4.x,
12
+ * ~> 1.7 for Rails 3.x,
13
+ * ~> 1.6.3 for Rails 2.3
14
+
15
+ Note: it is best to pin to a specific commit if using a development branch as sometimes tests break.
16
+
9
17
  health_check provides various monitoring URIs, for example:
10
18
 
11
19
  curl localhost:3000/health_check
@@ -24,6 +32,7 @@ health_check provides various monitoring URIs, for example:
24
32
  You may also issue POST calls instead of GET to these urls.
25
33
 
26
34
  On failure (detected by health_check) a 500 http status is returned with a simple explanation of the failure
35
+ (if include_error_in_response_body is true)
27
36
 
28
37
  curl localhost:3000/health_check/fail
29
38
  health_check failed: invalid argument to health_test.
@@ -39,10 +48,12 @@ The health_check controller disables sessions for versions that eagerly load ses
39
48
  * database - checks that the current migration level can be read from the database
40
49
  * email - basic check of email - :test returns true, :sendmail checks file is present and executable, :smtp sends HELO command to server and checks response
41
50
  * migration - checks that the database migration level matches that in db/migrations
51
+ * rabbitmq - RabbitMQ Health Check
42
52
  * redis / redis-if-present - checks Redis connectivity
43
53
  * resque-redis / resque-redis-if-present - checks Resque connectivity to Redis
44
54
  * s3 / s3-if-present - checks proper permissions to s3 buckets
45
55
  * sidekiq-redis / sidekiq-redis-if-present - checks Sidekiq connectivity to Redis
56
+ * elasticsearch / elasticsearch-if-present - checks Elasticsearch connectivity
46
57
  * site - checks rails is running sufficiently to render text
47
58
 
48
59
  Some checks have a *-if-present form, which only runs the check if the corresponding library has been required.
@@ -55,9 +66,9 @@ Note: rails also checks migrations by default in development mode and throws an
55
66
 
56
67
  == Installation
57
68
 
58
- Add the following line to Gemfile
69
+ Add the following line to Gemfile (after the rails gems are listed)
59
70
 
60
- gem "health_check"
71
+ gem 'health_check'
61
72
 
62
73
  And then execute
63
74
 
@@ -79,6 +90,16 @@ To change the configuration of health_check, create a file `config/initializers/
79
90
  # Text output upon success
80
91
  config.success = 'success'
81
92
 
93
+ # Text output upon failure
94
+ config.failure = 'health_check failed'
95
+
96
+ # Disable the error message to prevent /health_check from leaking
97
+ # sensitive information
98
+ config.include_error_in_response_body = false
99
+
100
+ # Log level (success or failure message with error details is sent to rails log unless this is set to nil)
101
+ config.log_level = 'info'
102
+
82
103
  # Timeout in seconds used when checking smtp server
83
104
  config.smtp_timeout = 30.0
84
105
 
@@ -89,7 +110,7 @@ To change the configuration of health_check, create a file `config/initializers/
89
110
  config.http_status_for_error_text = 500
90
111
 
91
112
  # http status code used when an error object is output (json or xml)
92
- # Set to 200 if you want your want to distinguish between partial (healthy property == false) and
113
+ # Set to 200 if you want to distinguish between partial (healthy property == false) and
93
114
  # total failure of rails application (http status of 500 etc)
94
115
 
95
116
  config.http_status_for_error_object = 500
@@ -129,15 +150,37 @@ To change the configuration of health_check, create a file `config/initializers/
129
150
  config.basic_auth_username = 'my_username'
130
151
  config.basic_auth_password = 'my_password'
131
152
 
132
- # Whitelist requesting IPs
133
- # Defaults to blank and allows any IP
134
- config.origin_ip_whitelist = %w(123.123.123.123)
153
+ # Whitelist requesting IPs by a list of IP and/or CIDR ranges, either IPv4 or IPv6 (uses IPAddr.include? method to check)
154
+ # Defaults to blank which allows any IP
155
+ config.origin_ip_whitelist = %w(123.123.123.123 10.11.12.0/24 2400:cb00::/32)
156
+
157
+ # Use ActionDispatch::Request's remote_ip method when behind a proxy to pick up the real remote IP for origin_ip_whitelist check
158
+ # Otherwise uses Rack::Request's ip method (the default, and always used by Middleware), which is more susceptable to spoofing
159
+ # See https://stackoverflow.com/questions/10997005/whats-the-difference-between-request-remote-ip-and-request-ip-in-rails
160
+ config.accept_proxied_requests = false
135
161
 
136
162
  # http status code used when the ip is not allowed for the request
137
163
  config.http_status_for_ip_whitelist_error = 403
138
164
 
139
- # When redis url is non-standard
140
- config.redis_url = 'redis_url'
165
+ # rabbitmq
166
+ config.rabbitmq_config = {}
167
+
168
+ # When redis url/password is non-standard
169
+ config.redis_url = 'redis_url' # default ENV['REDIS_URL']
170
+ # Only included if set, as url can optionally include passwords as well
171
+ config.redis_password = 'redis_password' # default ENV['REDIS_PASSWORD']
172
+
173
+ # Failure Hooks to do something more ...
174
+ # checks lists the checks requested
175
+ config.on_failure do |checks, msg|
176
+ # log msg somewhere
177
+ end
178
+
179
+ config.on_success do |checks|
180
+ # flag that everything is well
181
+ end
182
+
183
+
141
184
  end
142
185
 
143
186
  You may call add_custom_check multiple times with different tests. These tests will be included in the default list ("standard").
@@ -151,7 +194,7 @@ Install health_check as middleware if you want to sometimes ignore exceptions fr
151
194
  eg DB connection errors from QueryCache. The "middleware" check will fail if you have not installed health_check as middleware.
152
195
 
153
196
  To install health_check as middleware add the following line to the config/application.rb:
154
- config.middleware.insert_after "Rails::Rack::Logger", HealthCheck::MiddlewareHealthcheck
197
+ config.middleware.insert_after Rails::Rack::Logger, HealthCheck::MiddlewareHealthcheck
155
198
 
156
199
  Note: health_check is installed as a full rails engine even if it has been installed as middleware. This is so the
157
200
  remaining checks continue to run through the complete rails stack.
@@ -174,7 +217,6 @@ See
174
217
 
175
218
  * Pingdom Website Monitoring - https://www.pingdom.com
176
219
  * NewRelic Availability Monitoring - http://newrelic.com/docs/features/availability-monitoring-faq
177
- * Uptime by OpenACS - http://uptime.openacs.org/uptime/
178
220
  * Engine Yard's guide - https://support.cloud.engineyard.com/entries/20996821-monitor-application-uptime (although the guide is based on fitter_happier plugin it will also work with this gem)
179
221
  * Nagios check_http (with -s success) - https://www.nagios-plugins.org/doc/man/check_http.html
180
222
  * Any other montoring service that can be set to check for the word success in the text returned from a url
@@ -236,24 +278,31 @@ Last-modified is set to the current time (rounded down to a multiple of max_age
236
278
 
237
279
  == Known Issues
238
280
 
281
+ * See https://github.com/ianheggie/health_check/issues
239
282
  * No inline documentation for methods
240
283
  * <b>rvm gemsets breaks the test</b> - specifically <tt>rvm use 1.9.3</tt> works but <tt>rvm gemset use ruby-1.9.3-p385@health_check --create</tt> triggers a "Could not find gem 'coffee-rails (~> 3.2.1) ruby' in the gems available on this machine." error in the last call to bundle (installing health_check as a gem via a path into the temp railsapp)
241
284
 
242
285
  == Similar projects
243
286
 
244
287
  * fitter_happier plugin by atmos - plugin with similar goals, but not compatible with uptime, and does not check email gateway
288
+ * HealthBit - inspired by this gem but with a fresh start as a simpler rack only application, no travis CI tests (yet?) but looks interesting.
245
289
 
246
290
  == Testing
247
291
 
248
292
  === Automated testing and other checks
249
293
 
250
- * {<img src="https://travis-ci.org/ianheggie/health_check.svg?branch=rails5">}[https://travis-ci.org/ianheggie/health_check.svg?branch=rails5] - Travis CI
294
+ * {<img src="https://badge.fury.io/rb/health_check.svg" alt="Gem Version" />}[http://badge.fury.io/rb/health_check] - Latest Gem
295
+ * {<img src="https://travis-ci.org/ianheggie/health_check.svg">}[https://travis-ci.org/ianheggie/health_check] - Travis CI
296
+ * {<img src="https://codeclimate.com/github/ianheggie/health_check.svg" />}[https://codeclimate.com/github/ianheggie/health_check] - Code quality
297
+ * {<img src="https://gemnasium.com/ianheggie/health_check.svg">}[https://gemnasium.com/ianheggie/health_check] - Gem dependencies
251
298
 
252
299
  === Manual testing
253
300
 
254
- The instructions have been changed to using a vagrant virtual box for consistant results.
301
+ The instructions have been changed to using a vagrant virtual box for consistent results.
302
+
303
+ Install vagrant 1.9.7 or later and virtual_box or other local virtual machine provider. Add the vagrant plugin called vbguest.
255
304
 
256
- Install vagrant 1.9.7 or later and virtual_box or other local virtual machine providor.
305
+ vagrant plugin install vagrant-vbguest
257
306
 
258
307
  Create a temp directory for throw away testing, and clone the health_check gem into it
259
308
 
@@ -281,11 +330,11 @@ Cd to the checked out health_check directory and then run the test as follows:
281
330
 
282
331
  cd /vagrant # the current directory on your host is mounted here on the virtual machine
283
332
 
284
- chruby 2.2.2 # or some other ruby version
333
+ chruby 2.2.2 # or some other ruby version (run chruby with no arguments to see the current list)
285
334
 
286
335
  test/test_with_railsapp
287
336
 
288
- exit # from viretual machine when finished
337
+ exit # from virtual machine when finished
289
338
 
290
339
  The script will first call `test/setup_railsapp` to setup a rails app with health_check installed and then
291
340
  run up the rails server and perform veraious tests.
@@ -297,7 +346,7 @@ The command `rake test` will also launch these tests, except it cannot install t
297
346
 
298
347
  == Copyright
299
348
 
300
- Copyright (c) 2010-2017 Ian Heggie, released under the MIT license.
349
+ Copyright (c) 2010-2021 Ian Heggie, released under the MIT license.
301
350
  See MIT-LICENSE for details.
302
351
 
303
352
  == Contributors
@@ -306,10 +355,18 @@ Thanks go to the various people who have given feedback and suggestions via the
306
355
 
307
356
  === Contributing
308
357
 
358
+ Use gem versions for stable releases, or github branch / commits for development versions:
359
+ * for Rails 5.x and 6.x use feature branched off master {master}[https://github.com/ianheggie/health_check/tree/master] for development;
360
+ * for Rails 4.x use feature branches off the {rails4}[https://github.com/ianheggie/health_check/tree/rails4] stable branch for development;
361
+ * for Rails 3.x use feature branches off the {rails3}[https://github.com/ianheggie/health_check/tree/rails3] stable branch for development;
362
+ * for Rails 2.3 use feature branches off the {rails2.3}[https://github.com/ianheggie/health_check/tree/rails2.3] stable branch for development;
363
+
309
364
  1. Fork it
310
365
  2. Create your feature branch (`git checkout -b my-new-feature`)
311
- 3. Commit your changes (`git commit -am 'Add some feature'`)
312
- 4. Push to the branch (`git push origin my-new-feature`)
313
- 5. Create new Pull Request (Code with BDD tests are favoured)
366
+ 3. Create a test that confirms your changes work
367
+ 4. Update README.rdoc to explain enhancements, or add succinct comment in code when fixing bugs
368
+ 5. Commit your changes (`git commit -am 'Add some feature'`)
369
+ 6. Push to the branch (`git push origin my-new-feature`)
370
+ 7. Create new Pull Request (Code with BDD tests and documentation are highly favoured)
314
371
 
315
- <em>Feedback welcome! Especially with suggested replacement code and corresponding tests</em>
372
+ <em>Feedback welcome! Especially with suggested replacement code, tests and documentation</em>