health_check 2.5.0 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +2 -0
- data/.travis.yml +162 -111
- data/CHANGELOG +36 -0
- data/README.rdoc +109 -43
- data/Rakefile +1 -1
- data/Vagrantfile +32 -0
- data/config/routes.rb +1 -1
- data/health_check.gemspec +7 -6
- data/lib/health_check.rb +51 -6
- data/lib/health_check/elasticsearch_health_check.rb +15 -0
- data/lib/health_check/health_check_controller.rb +32 -25
- data/lib/health_check/health_check_routes.rb +1 -1
- data/lib/health_check/middleware_health_check.rb +6 -1
- data/lib/health_check/rabbitmq_health_check.rb +16 -0
- data/lib/health_check/redis_health_check.rb +20 -7
- data/lib/health_check/s3_health_check.rb +9 -14
- data/lib/health_check/utils.rb +55 -33
- data/lib/health_check/version.rb +1 -1
- data/test/fake_smtp_server +143 -24
- data/test/init_variables +19 -1
- data/test/migrate/nine/9_create_countries.rb +1 -1
- data/test/migrate/twelve/011_create_roles.roles.rb +1 -1
- data/test/migrate/twelve/012_create_users.rb +2 -2
- data/test/migrate/twelve/9_create_countries.rb +1 -1
- data/test/provision_vagrant +103 -0
- data/test/rails_5.0.gemfile +10 -7
- data/test/rails_5.1.gemfile +34 -0
- data/test/rails_5.2.gemfile +34 -0
- data/test/rails_6.0.gemfile +30 -0
- data/test/rails_6.1.gemfile +29 -0
- data/test/rails_6.2.gemfile +30 -0
- data/test/rails_edge.gemfile +14 -9
- data/test/setup_railsapp +175 -95
- data/test/test_with_railsapp +152 -46
- data/test/testurl +9 -0
- metadata +45 -22
- data/test/rails_4.0.gemfile +0 -33
- data/test/rails_4.1.gemfile +0 -33
- data/test/rails_4.2.gemfile +0 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 5a8f9b5697e674eadaf79c49e68c55ef01c794a1fdb07c094026000aaa140296
|
4
|
+
data.tar.gz: 7598cfd30e1896ced703f44eee24a9c5f10110e9874c7461d9a7b014a704a686
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 710941df9c976069d0a81cdd0f5e739bf82dd7b836c17d03c827b374988b729aa7f165101e87d1eef40a83312377338d8696a0e9b3a7961259babaee6e2a4925
|
7
|
+
data.tar.gz: 32b2cd9adde99918e95b9734a7ae8e096c7300c53c7385541f0e8fb31052ff3739d39858271f3deea316aed2925b2c3e5427bbc378ef8403392fa8a414bac05a
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -1,4 +1,7 @@
|
|
1
|
-
|
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:
|
@@ -15,6 +18,7 @@ before_install:
|
|
15
18
|
- gem update --system $RUBYGEMS_VERSION
|
16
19
|
- gem --version
|
17
20
|
- gem install bundler ${BUNDLER_VERSION:+-v} ${BUNDLER_VERSION}
|
21
|
+
- gem install smarter_bundler
|
18
22
|
- bundle --version
|
19
23
|
- mkdir -p tmp/bundle
|
20
24
|
|
@@ -22,17 +26,38 @@ bundler_args: "--binstubs"
|
|
22
26
|
|
23
27
|
script: ./test/test_with_railsapp
|
24
28
|
|
25
|
-
|
29
|
+
jobs:
|
26
30
|
fast_finish: true
|
27
31
|
|
28
32
|
allow_failures:
|
29
|
-
|
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
|
30
41
|
gemfile: test/rails_edge.gemfile
|
31
|
-
env:
|
42
|
+
env:
|
43
|
+
- RAILS_VERSION=edge
|
44
|
+
- MIDDLEWARE=YES
|
45
|
+
- SMTP_STARTTLS=DISABLED
|
32
46
|
|
33
47
|
- rvm: ruby-head
|
34
|
-
gemfile: test/
|
35
|
-
env:
|
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
|
+
|
36
61
|
|
37
62
|
include:
|
38
63
|
# -------------------------------------
|
@@ -40,128 +65,154 @@ matrix:
|
|
40
65
|
|
41
66
|
# ruby 5.0 Jun. 2016
|
42
67
|
|
43
|
-
- rvm: 2.3.1
|
44
|
-
gemfile: test/rails_5.0.gemfile
|
45
|
-
env: RAILS_VERSION=5.0 MIDDLEWARE=no
|
46
|
-
|
47
68
|
- rvm: 2.2.2
|
48
69
|
gemfile: test/rails_5.0.gemfile
|
49
|
-
env:
|
70
|
+
env:
|
71
|
+
- RAILS_VERSION=5.0
|
72
|
+
- MIDDLEWARE=no
|
73
|
+
- RUBYGEMS_VERSION=2.7.11
|
74
|
+
- BUNDLER_VERSION=1.17.3
|
50
75
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
- rvm: 2.1.2
|
58
|
-
gemfile: test/rails_4.2.gemfile
|
59
|
-
env: RAILS_SERVER=puma RAILS_VERSION=4.2 MIDDLEWARE=no
|
60
|
-
|
61
|
-
# Can't find i18n?? because it can't compile?
|
62
|
-
#- rvm: 2.1.2
|
63
|
-
# gemfile: test/rails_4.2.gemfile
|
64
|
-
# env: RAILS_SERVER=passenger RAILS_VERSION=4.2
|
65
|
-
|
66
|
-
- rvm: 2.1.2
|
67
|
-
gemfile: test/rails_4.2.gemfile
|
68
|
-
env: RAILS_SERVER=thin RAILS_VERSION=4.2 MIDDLEWARE=no
|
69
|
-
|
70
|
-
# No longer supported by travis
|
71
|
-
#- rvm: rbx-2.2.6
|
72
|
-
# gemfile: test/rails_4.0.gemfile
|
73
|
-
# env: RAILS_ENV2=development RAILS_VERSION=4.0
|
74
|
-
|
75
|
-
- rvm: 2.1.2
|
76
|
-
gemfile: test/rails_4.2.gemfile
|
77
|
-
env: RAILS_SERVER=unicorn RAILS_VERSION=4.2 MIDDLEWARE=no
|
78
|
-
|
79
|
-
# Disabled because it takes way too long (40+ mins)
|
80
|
-
# Temporary version lock until Bundler >= 1.13.2
|
81
|
-
# https://github.com/bundler/bundler/issues/4975
|
82
|
-
#- rvm: jruby-19mode
|
83
|
-
# gemfile: test/rails_4.2.gemfile
|
84
|
-
# env: BUNDLER_VERSION=1.12.5 RAILS_VERSION=4.2
|
85
|
-
|
86
|
-
# rails 4.1 April 8, 2014
|
87
|
-
|
88
|
-
- rvm: 2.1.2
|
89
|
-
gemfile: test/rails_4.1.gemfile
|
90
|
-
env: RAILS_VERSION=4.1 MIDDLEWARE=no
|
76
|
+
- rvm: 2.3.6
|
77
|
+
gemfile: test/rails_5.0.gemfile
|
78
|
+
env:
|
79
|
+
- RAILS_VERSION=5.0
|
80
|
+
- MIDDLEWARE=no
|
91
81
|
|
92
|
-
# rails
|
82
|
+
# rails 5.1 sometime before May 2017
|
93
83
|
|
94
|
-
- rvm:
|
95
|
-
gemfile: test/
|
96
|
-
env:
|
84
|
+
- rvm: 2.2.2
|
85
|
+
gemfile: test/rails_5.1.gemfile
|
86
|
+
env:
|
87
|
+
- RAILS_VERSION=5.1
|
88
|
+
- MIDDLEWARE=no
|
89
|
+
- RUBYGEMS_VERSION=2.7.11
|
90
|
+
- BUNDLER_VERSION=1.17.3
|
91
|
+
|
92
|
+
- rvm: 2.3.6
|
93
|
+
gemfile: test/rails_5.1.gemfile
|
94
|
+
env:
|
95
|
+
- RAILS_VERSION=5.1
|
96
|
+
- MIDDLEWARE=no
|
97
|
+
- BUNDLER_VERSION=1.17.3
|
98
|
+
|
99
|
+
- rvm: 2.4.3
|
100
|
+
gemfile: test/rails_5.1.gemfile
|
101
|
+
env:
|
102
|
+
- RAILS_VERSION=5.1
|
103
|
+
- MIDDLEWARE=no
|
97
104
|
|
98
105
|
# -------------------------------------
|
99
|
-
#
|
100
|
-
|
101
|
-
# ruby / rails edge
|
106
|
+
# Middleware
|
102
107
|
|
103
|
-
- rvm: 2.3.1
|
104
|
-
gemfile: test/rails_edge.gemfile
|
105
|
-
env: RAILS_VERSION=edge MIDDLEWARE=YES
|
106
|
-
|
107
108
|
# ruby 5.0 Jun. 2016
|
108
109
|
|
109
|
-
- rvm: 2.3.1
|
110
|
-
gemfile: test/rails_5.0.gemfile
|
111
|
-
env: RAILS_VERSION=5.0 MIDDLEWARE=YES
|
112
|
-
|
113
110
|
- rvm: 2.2.2
|
114
111
|
gemfile: test/rails_5.0.gemfile
|
115
|
-
env:
|
112
|
+
env:
|
113
|
+
- RAILS_VERSION=5.0
|
114
|
+
- MIDDLEWARE=yes
|
115
|
+
- RUBYGEMS_VERSION=2.7.11
|
116
|
+
- BUNDLER_VERSION=1.17.3
|
116
117
|
|
117
|
-
- rvm:
|
118
|
+
- rvm: 2.3.6
|
118
119
|
gemfile: test/rails_5.0.gemfile
|
119
|
-
env:
|
120
|
+
env:
|
121
|
+
- RAILS_VERSION=5.0
|
122
|
+
- MIDDLEWARE=yes
|
120
123
|
|
121
|
-
# rails
|
124
|
+
# rails 5.1 sometime before May 2017
|
122
125
|
|
123
|
-
- rvm: 2.2.
|
124
|
-
gemfile: test/
|
125
|
-
env:
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
#
|
141
|
-
#- rvm: rbx-2.2.6
|
142
|
-
# gemfile: test/rails_4.0.gemfile
|
143
|
-
# env: RAILS_ENV2=development RAILS_VERSION=4.0 MIDDLEWARE=YES
|
144
|
-
|
145
|
-
- rvm: 2.1.2
|
146
|
-
gemfile: test/rails_4.2.gemfile
|
147
|
-
env: RAILS_SERVER=unicorn RAILS_VERSION=4.2 MIDDLEWARE=YES
|
148
|
-
|
149
|
-
# Disabled because it takes way too long (40+ mins)
|
150
|
-
# Temporary version lock until Bundler >= 1.13.2
|
151
|
-
# https://github.com/bundler/bundler/issues/4975
|
152
|
-
#- rvm: jruby-19mode
|
153
|
-
# gemfile: test/rails_4.2.gemfile
|
154
|
-
# env: BUNDLER_VERSION=1.12.5 RAILS_VERSION=4.2 MIDDLEWARE=YES
|
155
|
-
|
156
|
-
# rails 4.1 April 8, 2014
|
126
|
+
- rvm: 2.2.2
|
127
|
+
gemfile: test/rails_5.1.gemfile
|
128
|
+
env:
|
129
|
+
- RAILS_VERSION=5.1
|
130
|
+
- MIDDLEWARE=yes
|
131
|
+
- RUBYGEMS_VERSION=2.7.11
|
132
|
+
- BUNDLER_VERSION=1.17.3
|
133
|
+
|
134
|
+
- rvm: 2.4.3
|
135
|
+
gemfile: test/rails_5.1.gemfile
|
136
|
+
env:
|
137
|
+
- RAILS_VERSION=5.1
|
138
|
+
- MIDDLEWARE=yes
|
139
|
+
|
140
|
+
|
141
|
+
# rails 5.2 April 2018
|
142
|
+
# -------------------------------------
|
143
|
+
# INSTALLED AS MIDDLEWARE
|
157
144
|
|
158
|
-
- rvm: 2.1.2
|
159
|
-
gemfile: test/rails_4.1.gemfile
|
160
|
-
env: RAILS_VERSION=4.1 MIDDLEWARE=YES
|
161
145
|
|
162
|
-
# rails
|
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
|
163
159
|
|
164
|
-
|
165
|
-
|
166
|
-
|
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
|
167
218
|
|
data/CHANGELOG
CHANGED
@@ -1,5 +1,41 @@
|
|
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
|
+
|
24
|
+
* 3.0.0
|
25
|
+
* First release on rails5 branch
|
26
|
+
* Depends on railties rather than rails so it can be used with trimmed down stacks
|
27
|
+
* Corrected ruby version required to match rails
|
28
|
+
* Cleaned up README
|
29
|
+
* redis_url now defaults to nil (url determined by redis gem)
|
30
|
+
* Cleaned out rails 4.0 dependent code
|
31
|
+
* Cleaned up test code and updated to rails 5 standards, uses smarter_bundler to handle gem ruby version isssues
|
32
|
+
* Added rails 5.1 test
|
33
|
+
* Split all releases to this rails* branchs - master is only for edge development
|
34
|
+
|
35
|
+
* 2.7.0
|
36
|
+
* Add ability to check health of redis when url is non-standard redis url
|
37
|
+
* 2.6.0
|
38
|
+
* Add named custom checks
|
3
39
|
* 2.5.0
|
4
40
|
* Added whitelist for IP# (Thanks Fernando Alvarez)
|
5
41
|
* reworked whitelist PR
|
data/README.rdoc
CHANGED
@@ -1,14 +1,19 @@
|
|
1
1
|
= health_check gem
|
2
2
|
|
3
|
-
Simple health check of Rails
|
4
|
-
|
5
|
-
Use
|
6
|
-
* {master}[https://github.com/ianheggie/health_check/tree/master] branch or gem versions ~> 2.0 for Rails 4.x and 5.x;
|
7
|
-
* {pre_rails4}[https://github.com/ianheggie/health_check/tree/pre_rails4] branch or gem versions ~> 1.7 for Rails 3.x;
|
8
|
-
* {rails2.3}[https://github.com/ianheggie/health_check/tree/rails2.3] branch or gem versions ~> 1.6.1 for Rails 2.3;
|
3
|
+
Simple health check of Rails 5.x and 6.x apps for use with Pingdom, NewRelic, EngineYard etc.
|
9
4
|
|
10
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)
|
11
6
|
|
7
|
+
Check the latest README {master}[https://github.com/ianheggie/health_check/tree/master] for other versions
|
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
|
+
|
12
17
|
health_check provides various monitoring URIs, for example:
|
13
18
|
|
14
19
|
curl localhost:3000/health_check
|
@@ -27,11 +32,12 @@ health_check provides various monitoring URIs, for example:
|
|
27
32
|
You may also issue POST calls instead of GET to these urls.
|
28
33
|
|
29
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)
|
30
36
|
|
31
37
|
curl localhost:3000/health_check/fail
|
32
38
|
health_check failed: invalid argument to health_test.
|
33
39
|
|
34
|
-
The health_check controller disables sessions for versions that eagerly load sessions.
|
40
|
+
The health_check controller disables sessions for versions that eagerly load sessions.
|
35
41
|
|
36
42
|
== Checks
|
37
43
|
|
@@ -42,10 +48,12 @@ The health_check controller disables sessions for versions that eagerly load ses
|
|
42
48
|
* database - checks that the current migration level can be read from the database
|
43
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
|
44
50
|
* migration - checks that the database migration level matches that in db/migrations
|
51
|
+
* rabbitmq - RabbitMQ Health Check
|
45
52
|
* redis / redis-if-present - checks Redis connectivity
|
46
53
|
* resque-redis / resque-redis-if-present - checks Resque connectivity to Redis
|
47
54
|
* s3 / s3-if-present - checks proper permissions to s3 buckets
|
48
55
|
* sidekiq-redis / sidekiq-redis-if-present - checks Sidekiq connectivity to Redis
|
56
|
+
* elasticsearch / elasticsearch-if-present - checks Elasticsearch connectivity
|
49
57
|
* site - checks rails is running sufficiently to render text
|
50
58
|
|
51
59
|
Some checks have a *-if-present form, which only runs the check if the corresponding library has been required.
|
@@ -54,13 +62,13 @@ The email gateway is not checked unless the smtp settings have been changed.
|
|
54
62
|
Specify full or include email in the list of checks to verify the smtp settings
|
55
63
|
(eg use 127.0.0.1 instead of localhost).
|
56
64
|
|
57
|
-
Note: rails
|
65
|
+
Note: rails also checks migrations by default in development mode and throws an ActiveRecord::PendingMigrationError exception (http error 500) if there is an error
|
58
66
|
|
59
67
|
== Installation
|
60
68
|
|
61
|
-
Add the following line to Gemfile
|
69
|
+
Add the following line to Gemfile (after the rails gems are listed)
|
62
70
|
|
63
|
-
gem
|
71
|
+
gem 'health_check'
|
64
72
|
|
65
73
|
And then execute
|
66
74
|
|
@@ -82,6 +90,16 @@ To change the configuration of health_check, create a file `config/initializers/
|
|
82
90
|
# Text output upon success
|
83
91
|
config.success = 'success'
|
84
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
|
+
|
85
103
|
# Timeout in seconds used when checking smtp server
|
86
104
|
config.smtp_timeout = 30.0
|
87
105
|
|
@@ -92,7 +110,7 @@ To change the configuration of health_check, create a file `config/initializers/
|
|
92
110
|
config.http_status_for_error_text = 500
|
93
111
|
|
94
112
|
# http status code used when an error object is output (json or xml)
|
95
|
-
# Set to 200 if you want
|
113
|
+
# Set to 200 if you want to distinguish between partial (healthy property == false) and
|
96
114
|
# total failure of rails application (http status of 500 etc)
|
97
115
|
|
98
116
|
config.http_status_for_error_object = 500
|
@@ -114,6 +132,13 @@ To change the configuration of health_check, create a file `config/initializers/
|
|
114
132
|
CustomHealthCheck.perform_check # any code that returns blank on success and non blank string upon failure
|
115
133
|
end
|
116
134
|
|
135
|
+
# Add another custom check with a name, so you can call just specific custom checks. This can also be run using
|
136
|
+
# the standard 'custom' check.
|
137
|
+
# You can define multiple tests under the same name - they will be run one after the other.
|
138
|
+
config.add_custom_check('sometest') do
|
139
|
+
CustomHealthCheck.perform_another_check # any code that returns blank on success and non blank string upon failure
|
140
|
+
end
|
141
|
+
|
117
142
|
# max-age of response in seconds
|
118
143
|
# cache-control is public when max_age > 1 and basic_auth_username is not set
|
119
144
|
# You can force private without authentication for longer max_age by
|
@@ -125,12 +150,37 @@ To change the configuration of health_check, create a file `config/initializers/
|
|
125
150
|
config.basic_auth_username = 'my_username'
|
126
151
|
config.basic_auth_password = 'my_password'
|
127
152
|
|
128
|
-
# Whitelist requesting IPs
|
129
|
-
# Defaults to blank
|
130
|
-
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
|
131
161
|
|
132
162
|
# http status code used when the ip is not allowed for the request
|
133
163
|
config.http_status_for_ip_whitelist_error = 403
|
164
|
+
|
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
|
+
|
134
184
|
end
|
135
185
|
|
136
186
|
You may call add_custom_check multiple times with different tests. These tests will be included in the default list ("standard").
|
@@ -144,7 +194,7 @@ Install health_check as middleware if you want to sometimes ignore exceptions fr
|
|
144
194
|
eg DB connection errors from QueryCache. The "middleware" check will fail if you have not installed health_check as middleware.
|
145
195
|
|
146
196
|
To install health_check as middleware add the following line to the config/application.rb:
|
147
|
-
config.middleware.insert_after
|
197
|
+
config.middleware.insert_after Rails::Rack::Logger, HealthCheck::MiddlewareHealthcheck
|
148
198
|
|
149
199
|
Note: health_check is installed as a full rails engine even if it has been installed as middleware. This is so the
|
150
200
|
remaining checks continue to run through the complete rails stack.
|
@@ -167,7 +217,6 @@ See
|
|
167
217
|
|
168
218
|
* Pingdom Website Monitoring - https://www.pingdom.com
|
169
219
|
* NewRelic Availability Monitoring - http://newrelic.com/docs/features/availability-monitoring-faq
|
170
|
-
* Uptime by OpenACS - http://uptime.openacs.org/uptime/
|
171
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)
|
172
221
|
* Nagios check_http (with -s success) - https://www.nagios-plugins.org/doc/man/check_http.html
|
173
222
|
* Any other montoring service that can be set to check for the word success in the text returned from a url
|
@@ -227,59 +276,66 @@ Cache-control is set with
|
|
227
276
|
|
228
277
|
Last-modified is set to the current time (rounded down to a multiple of max_age when max_age > 1)
|
229
278
|
|
230
|
-
== Note on Patches/Pull Requests
|
231
|
-
|
232
|
-
<em>Feedback welcome! Especially with suggested replacement code and corresponding tests</em>
|
233
|
-
|
234
|
-
1. Fork it
|
235
|
-
2. Create your feature branch (<tt>git checkout -b my-new-feature</tt>)
|
236
|
-
3. Commit your changes (<tt>git commit -am 'Add some feature'</tt>)
|
237
|
-
4. Push to the branch (<tt>git push origin my-new-feature</tt>)
|
238
|
-
5. Create new Pull Request.
|
239
|
-
|
240
279
|
== Known Issues
|
241
280
|
|
281
|
+
* See https://github.com/ianheggie/health_check/issues
|
242
282
|
* No inline documentation for methods
|
243
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)
|
244
284
|
|
245
285
|
== Similar projects
|
246
286
|
|
247
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.
|
248
289
|
|
249
290
|
== Testing
|
250
291
|
|
251
292
|
=== Automated testing and other checks
|
252
293
|
|
253
|
-
* {<img src="https://badge.fury.io/rb/health_check.
|
254
|
-
* {<img src="https://travis-ci.org/ianheggie/health_check.
|
255
|
-
* {<img src="https://codeclimate.com/github/ianheggie/health_check.
|
256
|
-
* {<img src="https://gemnasium.com/ianheggie/health_check.
|
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
|
257
298
|
|
258
299
|
=== Manual testing
|
259
300
|
|
260
|
-
The
|
261
|
-
install the gem, and then run up tests against the server.
|
262
|
-
This will require TCP port 3456 to be free.
|
301
|
+
The instructions have been changed to using a vagrant virtual box for consistent results.
|
263
302
|
|
264
|
-
|
265
|
-
You will need to install the bundler gem if using rbenv.
|
266
|
-
See the <tt>.travis.yml</tt> file for the list of ruby versions that we test against.
|
303
|
+
Install vagrant 1.9.7 or later and virtual_box or other local virtual machine provider. Add the vagrant plugin called vbguest.
|
267
304
|
|
268
|
-
|
269
|
-
* rvm command: <tt>rvm use 1.9.3</tt>
|
305
|
+
vagrant plugin install vagrant-vbguest
|
270
306
|
|
271
307
|
Create a temp directory for throw away testing, and clone the health_check gem into it
|
272
308
|
|
273
309
|
mkdir -p ~/tmp
|
274
310
|
cd ~/tmp
|
275
|
-
git clone https://github.com/ianheggie/health_check.git
|
311
|
+
git clone https://github.com/ianheggie/health_check.git ~/tmp/health_check
|
312
|
+
|
313
|
+
The Vagrantfile includes provisioning rules to install chruby (ruby version control),
|
314
|
+
ruby-build will also be installed and run to build various rubies under /opt/rubies.
|
315
|
+
|
316
|
+
Use <tt>vagrant ssh</tt> to connect to the virtual box and run tests.
|
317
|
+
|
318
|
+
The test script will package up and install the gem under a temporary path, create a dummy rails app configured for sqlite,
|
319
|
+
install the gem, and then run up tests against the server.
|
320
|
+
This will require TCP port 3456 to be free.
|
276
321
|
|
277
322
|
Cd to the checked out health_check directory and then run the test as follows:
|
278
323
|
|
279
324
|
cd ~/tmp/health_check
|
280
325
|
|
326
|
+
vagrant up # this will also run vagrant provision and take some time
|
327
|
+
# chruby and various ruby versions will be installed
|
328
|
+
|
329
|
+
vagrant ssh
|
330
|
+
|
331
|
+
cd /vagrant # the current directory on your host is mounted here on the virtual machine
|
332
|
+
|
333
|
+
chruby 2.2.2 # or some other ruby version (run chruby with no arguments to see the current list)
|
334
|
+
|
281
335
|
test/test_with_railsapp
|
282
336
|
|
337
|
+
exit # from virtual machine when finished
|
338
|
+
|
283
339
|
The script will first call `test/setup_railsapp` to setup a rails app with health_check installed and then
|
284
340
|
run up the rails server and perform veraious tests.
|
285
341
|
|
@@ -290,7 +346,7 @@ The command `rake test` will also launch these tests, except it cannot install t
|
|
290
346
|
|
291
347
|
== Copyright
|
292
348
|
|
293
|
-
Copyright (c) 2010-
|
349
|
+
Copyright (c) 2010-2021 Ian Heggie, released under the MIT license.
|
294
350
|
See MIT-LICENSE for details.
|
295
351
|
|
296
352
|
== Contributors
|
@@ -299,8 +355,18 @@ Thanks go to the various people who have given feedback and suggestions via the
|
|
299
355
|
|
300
356
|
=== Contributing
|
301
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
|
+
|
302
364
|
1. Fork it
|
303
365
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
304
|
-
3.
|
305
|
-
4.
|
306
|
-
5.
|
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)
|
371
|
+
|
372
|
+
<em>Feedback welcome! Especially with suggested replacement code, tests and documentation</em>
|