health_check 1.5.1 → 1.6.1
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.
- data/.gitignore +1 -0
- data/.travis.yml +7 -52
- data/CHANGELOG +7 -261
- data/Gemfile +11 -0
- data/README.rdoc +8 -3
- data/health_check.gemspec +2 -2
- data/lib/health_check/health_check_controller.rb +9 -1
- data/lib/health_check/version.rb +1 -1
- data/lib/health_check.rb +6 -0
- data/test/rails_2.3.gemfile +8 -3
- data/test/rails_2.3_lts.gemfile +41 -0
- data/test/setup_railsapp +42 -33
- metadata +96 -59
- data/test/rails_3.0.gemfile +0 -16
- data/test/rails_3.1.gemfile +0 -24
- data/test/rails_3.2.gemfile +0 -23
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -15,64 +15,19 @@ bundler_args: "--binstubs"
|
|
15
15
|
|
16
16
|
script: ./test/test_with_railsapp
|
17
17
|
|
18
|
-
rvm:
|
19
|
-
- 1.9.3
|
20
|
-
|
21
|
-
gemfile:
|
22
|
-
- test/rails_3.2.gemfile
|
23
|
-
|
24
18
|
matrix:
|
25
19
|
allow_failures:
|
20
|
+
- rvm: 1.8.7
|
21
|
+
gemfile: test/rails_2.3_lts.gemfile
|
22
|
+
env: RUBYGEMS_VERSION=1.8.25 RAILS_VERSION=2.3
|
26
23
|
|
27
24
|
include:
|
28
|
-
# rails 3
|
29
|
-
|
30
|
-
- rvm: 1.9.3
|
31
|
-
gemfile: test/rails_3.2.gemfile
|
32
|
-
env: RAILS_SERVER=puma RAILS_VERSION=3.2
|
33
|
-
|
34
|
-
- rvm: 1.9.3
|
35
|
-
gemfile: test/rails_3.2.gemfile
|
36
|
-
env: RAILS_SERVER=passenger RAILS_VERSION=3.2
|
37
|
-
|
38
|
-
- rvm: 1.9.3
|
39
|
-
gemfile: test/rails_3.2.gemfile
|
40
|
-
env: RAILS_SERVER=thin RAILS_VERSION=3.2
|
41
|
-
|
42
|
-
- rvm: rbx-2.2.6
|
43
|
-
gemfile: test/rails_3.2.gemfile
|
44
|
-
env: RAILS_ENV2=development RAILS_VERSION=3.2
|
45
|
-
|
46
|
-
- rvm: 1.9.3
|
47
|
-
gemfile: test/rails_3.2.gemfile
|
48
|
-
env: RAILS_SERVER=unicorn RAILS_VERSION=3.2
|
49
|
-
|
50
|
-
- rvm: jruby-19mode
|
51
|
-
gemfile: test/rails_3.2.gemfile
|
52
|
-
env: RAILS_VERSION=3.2
|
53
|
-
|
54
|
-
- rvm: 2.2.0
|
55
|
-
gemfile: test/rails_3.2.gemfile
|
56
|
-
env: RAILS_VERSION=3.2
|
57
|
-
|
58
|
-
- rvm: 1.9.3
|
59
|
-
gemfile: test/rails_3.2.gemfile
|
60
|
-
env: RAILS_VERSION=3.2
|
61
|
-
|
62
|
-
- rvm: jruby-19mode
|
63
|
-
gemfile: test/rails_3.2.gemfile
|
64
|
-
env: RAILS_VERSION=3.2
|
65
|
-
|
66
|
-
# rails 3.1 aug 31, 2011 - ruby 1.8.7 or 1.9.2
|
67
|
-
- rvm: 1.9.2
|
68
|
-
gemfile: test/rails_3.1.gemfile
|
69
|
-
env: RAILS_VERSION=3.1
|
70
|
-
|
25
|
+
# rails 2.3 march 16 2009 - ruby 1.8.7
|
26
|
+
# railslts.com
|
71
27
|
- rvm: 1.8.7
|
72
|
-
gemfile: test/
|
73
|
-
env: RAILS_VERSION=3
|
28
|
+
gemfile: test/rails_2.3_lts.gemfile
|
29
|
+
env: RUBYGEMS_VERSION=1.8.25 RAILS_VERSION=2.3
|
74
30
|
|
75
|
-
# rails 2.3 march 16 2009 - ruby 1.8.7
|
76
31
|
- rvm: 1.8.7
|
77
32
|
gemfile: test/rails_2.3.gemfile
|
78
33
|
env: RUBYGEMS_VERSION=1.8.25 RAILS_VERSION=2.3
|
data/CHANGELOG
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
= Change Log =
|
2
2
|
|
3
|
+
* rails2.3 branch
|
4
|
+
*1.6.1 - rails 2.3 only version
|
5
|
+
* rails 2.3 only version
|
6
|
+
*1.6.0
|
7
|
+
* Added basic auth support - Thanks Kyle Conarro <kyle.conarro@gmail.com>
|
8
|
+
* Explicitly limit rails to < 4.0 for this branch
|
9
|
+
* Test against rails 2.3 LTS, updated gemfile's used for testing as the latest version of gems become incompatible
|
3
10
|
*1.5.1
|
4
11
|
* Created pre_rails4 branch (versions < 2.0) for rails 2.3 and 3.x; with master branch for rails 4.0+
|
5
12
|
*1.5.0
|
@@ -23,264 +30,3 @@
|
|
23
30
|
* 1.x - Includes Rails 3.x suppprt as an Engine
|
24
31
|
* 0.x - Rails 2.3
|
25
32
|
|
26
|
-
+
|
27
|
-
end
|
28
|
-
|
29
|
-
diff --git a/README.rdoc b/README.rdoc
|
30
|
-
index de48110..cf673e8 100644
|
31
|
-
--- a/README.rdoc
|
32
|
-
+++ b/README.rdoc
|
33
|
-
@@ -24,11 +24,11 @@ On failure a 500 http status is returned with a simple explanation of the failur
|
34
|
-
curl localhost:3000/health_check/fail
|
35
|
-
health_check failed: invalid argument to health_test.
|
36
|
-
|
37
|
-
-The health_check controller disables sessions and logging for its actions to minimise the impact of frequent uptime checks on the session store and the log file.
|
38
|
-
+The health_check controller disables sessions for versions that eagerly load sessions. Only failures are logged for rails < '4.1'.
|
39
|
-
|
40
|
-
== Checks
|
41
|
-
|
42
|
-
-* standard (default) - site, database and migrations checks are run plus email if settings have been changed
|
43
|
-
+* standard (default) - site, database and migrations checks are run plus email if ActionMailer is defined and it is not using the default configuration
|
44
|
-
* all / full - all checks are run (can be overriden in config block)
|
45
|
-
* database - checks that the current migration level can be read from the database
|
46
|
-
* email - basic check of email - :test returns true, :sendmail checks file is present and executable, :smtp sends HELO command to server and checks response
|
47
|
-
@@ -100,6 +100,9 @@ To change the configuration of health_check, create a file `config/initializers/
|
48
|
-
|
49
|
-
config.http_status_for_error_object = 500
|
50
|
-
|
51
|
-
+ # You can customize which checks happen on a standard health check
|
52
|
-
+ config.standard_checks = [ 'database', 'migrations', 'custom' ]
|
53
|
-
+
|
54
|
-
# You can set what tests are run with the 'full' or 'all' parameter
|
55
|
-
config.full_checks = ['database', 'migrations', 'custom', 'email', 'cache']
|
56
|
-
|
57
|
-
@@ -189,11 +192,10 @@ See https://github.com/ianheggie/health_check/wiki/Ajax-Example for an Ajax exam
|
58
|
-
|
59
|
-
=== Automated testing and other checks
|
60
|
-
|
61
|
-
-Travis CI runs the tests: {<img src="https://travis-ci.org/ianheggie/health_check.png">}[https://travis-ci.org/ianheggie/health_check]
|
62
|
-
-
|
63
|
-
-Code Climate monitors code quality: {<img src="https://codeclimate.com/github/ianheggie/health_check.png" />}[https://codeclimate.com/github/ianheggie/health_check]
|
64
|
-
-
|
65
|
-
-Gemnasium monitors gem dependencies {<img src="https://gemnasium.com/ianheggie/health_check.png">}[https://gemnasium.com/ianheggie/health_check]
|
66
|
-
+* {<img src="https://badge.fury.io/rb/health_check.png" alt="Gem Version" />}[http://badge.fury.io/rb/health_check] - Latest Gem
|
67
|
-
+* {<img src="https://travis-ci.org/ianheggie/health_check.png">}[https://travis-ci.org/ianheggie/health_check] - Travis CI
|
68
|
-
+* {<img src="https://codeclimate.com/github/ianheggie/health_check.png" />}[https://codeclimate.com/github/ianheggie/health_check] - Code quality
|
69
|
-
+* {<img src="https://gemnasium.com/ianheggie/health_check.png">}[https://gemnasium.com/ianheggie/health_check] - Gem dependencies
|
70
|
-
|
71
|
-
=== Manual testing
|
72
|
-
|
73
|
-
@@ -230,10 +232,18 @@ The command `rake test` will also launch these tests, except it cannot install t
|
74
|
-
|
75
|
-
== Copyright
|
76
|
-
|
77
|
-
-Copyright (c) 2010-2013 Ian Heggie, released under the MIT license.
|
78
|
-
+Copyright (c) 2010-2014 Ian Heggie, released under the MIT license.
|
79
|
-
See MIT-LICENSE for details.
|
80
|
-
|
81
|
-
== Contributors
|
82
|
-
|
83
|
-
-Thanks go to the various people who have given feedback and suggestions via the issues list and pull requests
|
84
|
-
+Thanks go to the various people who have given feedback and suggestions via the issues list and pull requests.
|
85
|
-
+
|
86
|
-
+=== Contributing
|
87
|
-
+
|
88
|
-
+1. Fork it
|
89
|
-
+2. Create your feature branch (`git checkout -b my-new-feature`)
|
90
|
-
+3. Commit your changes (`git commit -am 'Add some feature'`)
|
91
|
-
+4. Push to the branch (`git push origin my-new-feature`)
|
92
|
-
+5. Create new Pull Request (Code with BDD tests are favoured)
|
93
|
-
|
94
|
-
diff --git a/health_check.gemspec b/health_check.gemspec
|
95
|
-
index 1b7f8fc..e6b70f5 100644
|
96
|
-
--- a/health_check.gemspec
|
97
|
-
+++ b/health_check.gemspec
|
98
|
-
@@ -13,7 +13,7 @@ Gem::Specification.new do |gem|
|
99
|
-
gem.description = <<-EOF
|
100
|
-
Simple health check of Rails app for uptime monitoring with Pingdom, NewRelic, EngineYard or uptime.openacs.org etc.
|
101
|
-
EOF
|
102
|
-
- gem.homepage = "http://ianheggie.github.io/health_check/"
|
103
|
-
+ gem.homepage = "https://github.com/ianheggie/health_check"
|
104
|
-
|
105
|
-
gem.files = `git ls-files`.split($/)
|
106
|
-
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
107
|
-
@@ -23,6 +23,5 @@ Gem::Specification.new do |gem|
|
108
|
-
gem.add_dependency(%q<rails>, [">= 2.3.0"])
|
109
|
-
gem.add_development_dependency(%q<rake>, [">= 0.8.3"])
|
110
|
-
gem.add_development_dependency(%q<shoulda>, ["~> 2.11.0"])
|
111
|
-
- gem.add_development_dependency(%q<sqlite3>, ["~> 1.3.7"])
|
112
|
-
gem.add_development_dependency(%q<bundler>, ["~> 1.2"])
|
113
|
-
end
|
114
|
-
diff --git a/lib/health_check.rb b/lib/health_check.rb
|
115
|
-
index 04d6aec..45f8fd2 100644
|
116
|
-
--- a/lib/health_check.rb
|
117
|
-
+++ b/lib/health_check.rb
|
118
|
-
@@ -28,8 +28,10 @@ module HealthCheck
|
119
|
-
# Array of custom check blocks
|
120
|
-
mattr_accessor :custom_checks
|
121
|
-
mattr_accessor :full_checks
|
122
|
-
+ mattr_accessor :standard_checks
|
123
|
-
self.custom_checks = [ ]
|
124
|
-
self.full_checks = ['database', 'migrations', 'custom', 'email', 'cache']
|
125
|
-
+ self.standard_checks = [ 'database', 'migrations', 'custom' ]
|
126
|
-
|
127
|
-
def self.add_custom_check(&block)
|
128
|
-
custom_checks << block
|
129
|
-
diff --git a/lib/health_check/health_check_controller.rb b/lib/health_check/health_check_controller.rb
|
130
|
-
index 4b5fa7a..7d544f7 100644
|
131
|
-
--- a/lib/health_check/health_check_controller.rb
|
132
|
-
+++ b/lib/health_check/health_check_controller.rb
|
133
|
-
@@ -4,8 +4,6 @@
|
134
|
-
module HealthCheck
|
135
|
-
class HealthCheckController < ActionController::Base
|
136
|
-
|
137
|
-
- session(:off) if Rails.version < '3.0'
|
138
|
-
-
|
139
|
-
layout false if self.respond_to? :layout
|
140
|
-
|
141
|
-
def index
|
142
|
-
@@ -34,9 +32,9 @@ module HealthCheck
|
143
|
-
end
|
144
|
-
# Log a single line as some uptime checkers only record that it failed, not the text returned
|
145
|
-
if logger
|
146
|
-
- silence_level, logger.level = logger.level, @old_logger_level
|
147
|
-
+ silence_level, logger.level = logger.level, @old_logger_level if @old_logger_level
|
148
|
-
logger.info msg
|
149
|
-
- logger.level = silence_level
|
150
|
-
+ logger.level = silence_level if @old_logger_level
|
151
|
-
end
|
152
|
-
end
|
153
|
-
end
|
154
|
-
diff --git a/lib/health_check/utils.rb b/lib/health_check/utils.rb
|
155
|
-
index b6da3f8..e7a10f6 100644
|
156
|
-
--- a/lib/health_check/utils.rb
|
157
|
-
+++ b/lib/health_check/utils.rb
|
158
|
-
@@ -46,8 +46,8 @@ module HealthCheck
|
159
|
-
when 'cache'
|
160
|
-
errors << HealthCheck::Utils.check_cache
|
161
|
-
when "standard"
|
162
|
-
- errors << HealthCheck::Utils.process_checks("database_migrations_custom")
|
163
|
-
- errors << HealthCheck::Utils.process_checks("email") unless HealthCheck::Utils.default_action_mailer_configuration?
|
164
|
-
+ errors << HealthCheck::Utils.process_checks(HealthCheck.standard_checks.join('_'))
|
165
|
-
+ errors << HealthCheck::Utils.process_checks("email") if HealthCheck::Utils.mailer_configured?
|
166
|
-
when "custom"
|
167
|
-
HealthCheck.custom_checks.each do |custom_check|
|
168
|
-
errors << custom_check.call(self)
|
169
|
-
@@ -71,8 +71,8 @@ module HealthCheck
|
170
|
-
@@db_migrate_path = value
|
171
|
-
end
|
172
|
-
|
173
|
-
- def self.default_action_mailer_configuration?
|
174
|
-
- ActionMailer::Base.delivery_method == :smtp && HealthCheck::Utils.default_smtp_settings == ActionMailer::Base.smtp_settings
|
175
|
-
+ def self.mailer_configured?
|
176
|
-
+ defined?(ActionMailer::Base) && (ActionMailer::Base.delivery_method != :smtp || HealthCheck::Utils.default_smtp_settings != ActionMailer::Base.smtp_settings)
|
177
|
-
end
|
178
|
-
|
179
|
-
def self.get_database_version
|
180
|
-
@@ -117,11 +117,11 @@ module HealthCheck
|
181
|
-
while status != nil && status !~ /^2/
|
182
|
-
status = t.gets
|
183
|
-
end
|
184
|
-
- t.puts "HELO #{settings[:domain]}"
|
185
|
-
+ t.puts "HELO #{settings[:domain]}\r"
|
186
|
-
while status != nil && status !~ /^250/
|
187
|
-
status = t.gets
|
188
|
-
end
|
189
|
-
- t.puts "QUIT"
|
190
|
-
+ t.puts "QUIT\r"
|
191
|
-
status = t.gets
|
192
|
-
ensure
|
193
|
-
t.close
|
194
|
-
diff --git a/lib/health_check/version.rb b/lib/health_check/version.rb
|
195
|
-
index 8264365..0cf2f60 100644
|
196
|
-
--- a/lib/health_check/version.rb
|
197
|
-
+++ b/lib/health_check/version.rb
|
198
|
-
@@ -1,4 +1,4 @@
|
199
|
-
module HealthCheck
|
200
|
-
- VERSION = "1.4.1"
|
201
|
-
+ VERSION = "1.5.0"
|
202
|
-
end
|
203
|
-
|
204
|
-
diff --git a/test/fake_smtp_server b/test/fake_smtp_server
|
205
|
-
index e55ee3a..7f1e645 100755
|
206
|
-
--- a/test/fake_smtp_server
|
207
|
-
+++ b/test/fake_smtp_server
|
208
|
-
@@ -23,8 +23,8 @@ client = server.accept # Wait for a client to connect
|
209
|
-
send(client, "220 dummy-smtp.example.com SMTP")
|
210
|
-
cmd = receive(client)
|
211
|
-
|
212
|
-
-while cmd !~ /^QUIT/
|
213
|
-
- if cmd =~ /^HELO/
|
214
|
-
+while cmd !~ /^QUIT\r/
|
215
|
-
+ if cmd =~ /^HELO(.*)\r/
|
216
|
-
send(client, "250 Welcome to a dummy smtp server")
|
217
|
-
else
|
218
|
-
send(client, "502 I am so dumb I only understand HELO and QUIT")
|
219
|
-
diff --git a/test/rails_2.3.gemfile b/test/rails_2.3.gemfile
|
220
|
-
index 80aa9fc..e30fa69 100644
|
221
|
-
--- a/test/rails_2.3.gemfile
|
222
|
-
+++ b/test/rails_2.3.gemfile
|
223
|
-
@@ -13,6 +13,9 @@ gem 'rails', "~> 2.3.15"
|
224
|
-
gem 'rdoc'
|
225
|
-
gem 'rdoc-data'
|
226
|
-
|
227
|
-
+# mime-types 2.0 requires Ruby version >= 1.9.2
|
228
|
-
+gem "mime-types", "< 2.0"
|
229
|
-
+
|
230
|
-
group :development, :test do
|
231
|
-
if defined?(JRUBY_VERSION)
|
232
|
-
gem 'jruby-openssl'
|
233
|
-
diff --git a/test/rails_4.1.gemfile b/test/rails_4.1.gemfile
|
234
|
-
new file mode 100644
|
235
|
-
index 0000000..b199010
|
236
|
-
--- /dev/null
|
237
|
-
+++ b/test/rails_4.1.gemfile
|
238
|
-
@@ -0,0 +1,19 @@
|
239
|
-
+# Gemfile for health_test testing
|
240
|
-
+
|
241
|
-
+source 'https://rubygems.org'
|
242
|
-
+
|
243
|
-
+ruby '1.9.3' if RUBY_VERSION < '1.9.3'
|
244
|
-
+
|
245
|
-
+gem 'rails', "~> 4.1.0"
|
246
|
-
+gem 'rake', '>= 0.8.3'
|
247
|
-
+gem "rack", '~> 1.5.2'
|
248
|
-
+
|
249
|
-
+group :development, :test do
|
250
|
-
+ if defined?(JRUBY_VERSION)
|
251
|
-
+ gem 'jruby-openssl'
|
252
|
-
+ gem 'activerecord-jdbcsqlite3-adapter'
|
253
|
-
+ else
|
254
|
-
+ gem 'sqlite3', "~> 1.3.7"
|
255
|
-
+ end
|
256
|
-
+ gem 'shoulda'
|
257
|
-
+end
|
258
|
-
diff --git a/test/setup_railsapp b/test/setup_railsapp
|
259
|
-
index 5f414f9..80f6116 100755
|
260
|
-
--- a/test/setup_railsapp
|
261
|
-
+++ b/test/setup_railsapp
|
262
|
-
@@ -164,6 +164,9 @@ then
|
263
|
-
echo ================= Gemfile ===================
|
264
|
-
cat Gemfile
|
265
|
-
echo
|
266
|
-
+ echo ================= Gemfile.lock ===================
|
267
|
-
+ cat Gemfile.lock
|
268
|
-
+ echo
|
269
|
-
else
|
270
|
-
dest=$railsapp/vendor/plugins/health_check
|
271
|
-
echo Installing health_check as plugin in $dest ...
|
272
|
-
diff --git a/test/test_with_railsapp b/test/test_with_railsapp
|
273
|
-
index 2ba4bc4..c866c68 100755
|
274
|
-
--- a/test/test_with_railsapp
|
275
|
-
+++ b/test/test_with_railsapp
|
276
|
-
@@ -306,6 +306,10 @@ common_tests()
|
277
|
-
date > $custom_file
|
278
|
-
}
|
279
|
-
|
280
|
-
+
|
281
|
-
+# required for rails 4.1+ in production mode
|
282
|
-
+export SECRET_KEY_BASE=cf2f49c38a3fe67416ddf680f4f3187c0fce7dd1b9b117b34d195df75b274e08a04877e23803b2fdf1aa9a655269d94bc4888aa325cf7e721cc47368cfe56a80
|
283
|
-
+
|
284
|
-
echo ========================================================
|
285
|
-
echo TESTING WITHOUT CATCHALL in test env
|
286
|
-
echo ========================================================
|
data/Gemfile
CHANGED
@@ -7,6 +7,15 @@ ruby '1.9.3' if RUBY_VERSION > '1.9.3'
|
|
7
7
|
|
8
8
|
gemspec
|
9
9
|
|
10
|
+
# mime-types 2.0 requires Ruby version >= 1.9.2
|
11
|
+
gem "mime-types", "< 2.0" if RUBY_VERSION < '1.9.2' # REQUIRED
|
12
|
+
# 0.7 requires ruby 1.9.3
|
13
|
+
gem 'i18n', '< 0.7' if RUBY_VERSION < '1.9.3' # REQUIRED
|
14
|
+
# rack 2.0 requires ruby 2.2.2, rails 3.2 requires rack ~> 1.4.5
|
15
|
+
gem 'rack', "< 1.5" # REQUIRED
|
16
|
+
|
17
|
+
gem 'rack-cache', '< 1.3' if RUBY_VERSION < '1.9.3'
|
18
|
+
|
10
19
|
group :development, :test do
|
11
20
|
if defined?(JRUBY_VERSION)
|
12
21
|
gem 'jruby-openssl'
|
@@ -20,6 +29,8 @@ group :development, :test do
|
|
20
29
|
# mime-types 2.0 requires Ruby version >= 1.9.2
|
21
30
|
gem "mime-types", "< 2.0"
|
22
31
|
end
|
32
|
+
#gem 'rake', ">= 0.8.3", "< 11.0"
|
33
|
+
#gem 'rack', "< 2.0"
|
23
34
|
|
24
35
|
end
|
25
36
|
|
data/README.rdoc
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
-
= health_check gem (
|
1
|
+
= health_check gem (rails2.3 branch)
|
2
2
|
|
3
3
|
Simple health check of Rails app for use with Pingdom, NewRelic, EngineYard or uptime.openacs.org etc.
|
4
4
|
|
5
|
-
Use {
|
5
|
+
Use {rails2.3}[https://github.com/ianheggie/health_check/tree/rails2.3] branch or gem versions ~> 1.6.0 for Rails 2.3.
|
6
|
+
See {master}[https://github.com/ianheggie/health_check/tree/master] branch for using with later versions.
|
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
|
|
@@ -45,7 +46,7 @@ Specify full or include email in the list of checks to verify the smtp settings
|
|
45
46
|
|
46
47
|
== Installation
|
47
48
|
|
48
|
-
=== As a Gem from rubygems (
|
49
|
+
=== As a Gem from rubygems (if you have modified your rails to use bundler)
|
49
50
|
|
50
51
|
Add the following line to Gemfile
|
51
52
|
|
@@ -111,6 +112,10 @@ To change the configuration of health_check, create a file `config/initializers/
|
|
111
112
|
CustomHealthCheck.perform_check # any code that returns blank on success and non blank string upon failure
|
112
113
|
end
|
113
114
|
|
115
|
+
# Protect health endpoints with basic auth
|
116
|
+
# These default to nil and the endpoint is not protected
|
117
|
+
config.basic_auth_username = 'my_username'
|
118
|
+
config.basic_auth_password = 'my_password'
|
114
119
|
end
|
115
120
|
|
116
121
|
You may call add_custom_check multiple times with different tests. These tests will be included in the default list ("standard").
|
data/health_check.gemspec
CHANGED
@@ -20,8 +20,8 @@ Gem::Specification.new do |gem|
|
|
20
20
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
21
21
|
gem.extra_rdoc_files = [ "README.rdoc" ]
|
22
22
|
gem.require_paths = ["lib"]
|
23
|
-
gem.add_dependency(%q<rails>, [
|
24
|
-
gem.add_development_dependency(%q<rake>, [">= 0.8.3"])
|
23
|
+
gem.add_dependency(%q<rails>, ['~> 2.3.0'])
|
24
|
+
gem.add_development_dependency(%q<rake>, [">= 0.8.3", "< 11.0"])
|
25
25
|
gem.add_development_dependency(%q<shoulda>, ["~> 2.11.0"])
|
26
26
|
gem.add_development_dependency(%q<bundler>, ["~> 1.2"])
|
27
27
|
end
|
@@ -5,6 +5,7 @@ module HealthCheck
|
|
5
5
|
class HealthCheckController < ActionController::Base
|
6
6
|
|
7
7
|
layout false if self.respond_to? :layout
|
8
|
+
before_filter :authenticate
|
8
9
|
|
9
10
|
def index
|
10
11
|
checks = params[:checks] || 'standard'
|
@@ -12,7 +13,7 @@ module HealthCheck
|
|
12
13
|
errors = HealthCheck::Utils.process_checks(checks)
|
13
14
|
rescue Exception => e
|
14
15
|
errors = e.message
|
15
|
-
end
|
16
|
+
end
|
16
17
|
if errors.blank?
|
17
18
|
obj = { :healthy => true, :message => HealthCheck.success }
|
18
19
|
respond_to do |format|
|
@@ -42,6 +43,13 @@ module HealthCheck
|
|
42
43
|
|
43
44
|
protected
|
44
45
|
|
46
|
+
def authenticate
|
47
|
+
return unless HealthCheck.basic_auth_username && HealthCheck.basic_auth_password
|
48
|
+
authenticate_or_request_with_http_basic do |username, password|
|
49
|
+
username == HealthCheck.basic_auth_username && password == HealthCheck.basic_auth_password
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
45
53
|
# turn cookies for CSRF off
|
46
54
|
def protect_against_forgery?
|
47
55
|
false
|
data/lib/health_check/version.rb
CHANGED
data/lib/health_check.rb
CHANGED
@@ -25,6 +25,12 @@ module HealthCheck
|
|
25
25
|
mattr_accessor :http_status_for_error_object
|
26
26
|
self.http_status_for_error_object = 500
|
27
27
|
|
28
|
+
#
|
29
|
+
mattr_accessor :basic_auth_username, :basic_auth_password
|
30
|
+
self.basic_auth_username = nil
|
31
|
+
self.basic_auth_password = nil
|
32
|
+
|
33
|
+
|
28
34
|
# Array of custom check blocks
|
29
35
|
mattr_accessor :custom_checks
|
30
36
|
mattr_accessor :full_checks
|
data/test/rails_2.3.gemfile
CHANGED
@@ -7,14 +7,19 @@ source 'https://rubygems.org'
|
|
7
7
|
|
8
8
|
ruby "1.8.7"
|
9
9
|
|
10
|
-
gem 'rails',
|
11
|
-
|
10
|
+
gem 'rails', '~>2.3.18'
|
11
|
+
|
12
|
+
gem 'rake', ">= 0.8.3", "< 11.0" # REQUIRED
|
12
13
|
|
13
14
|
gem 'rdoc'
|
14
15
|
gem 'rdoc-data'
|
15
16
|
|
16
17
|
# mime-types 2.0 requires Ruby version >= 1.9.2
|
17
|
-
gem "mime-types", "< 2.0"
|
18
|
+
gem "mime-types", "< 2.0" if RUBY_VERSION < '1.9.2' # REQUIRED
|
19
|
+
# 0.7 requires ruby 1.9.3
|
20
|
+
gem 'i18n', '< 0.7' if RUBY_VERSION < '1.9.3' # REQUIRED
|
21
|
+
# rack 2.0 requires ruby 2.2.2, rails 3.2 requires rack ~> 1.4.5
|
22
|
+
gem 'rack', "< 1.5" # REQUIRED
|
18
23
|
|
19
24
|
group :development, :test do
|
20
25
|
if defined?(JRUBY_VERSION)
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# Gemfile for health_test testing
|
2
|
+
|
3
|
+
source 'https://rubygems.org'
|
4
|
+
|
5
|
+
# Last rubygems version before 2.0.0 (which breaks rails 2.3)
|
6
|
+
#rubygems 1.8.25
|
7
|
+
|
8
|
+
ruby "1.8.7"
|
9
|
+
|
10
|
+
git 'https://github.com/makandra/rails.git', :branch => '2-3-lts' do
|
11
|
+
gem 'rails', '~>2.3.18'
|
12
|
+
gem 'actionmailer', :require => false
|
13
|
+
gem 'actionpack', :require => false
|
14
|
+
gem 'activerecord', :require => false
|
15
|
+
gem 'activeresource', :require => false
|
16
|
+
gem 'activesupport', :require => false
|
17
|
+
gem 'railties', :require => false
|
18
|
+
gem 'railslts-version', :require => false
|
19
|
+
end
|
20
|
+
|
21
|
+
gem 'rake', ">= 0.8.3", "< 11.0" # REQUIRED
|
22
|
+
|
23
|
+
gem 'rdoc'
|
24
|
+
gem 'rdoc-data'
|
25
|
+
|
26
|
+
# mime-types 2.0 requires Ruby version >= 1.9.2
|
27
|
+
gem "mime-types", "< 2.0" if RUBY_VERSION < '1.9.2' # REQUIRED
|
28
|
+
# 0.7 requires ruby 1.9.3
|
29
|
+
gem 'i18n', '< 0.7' if RUBY_VERSION < '1.9.3' # REQUIRED
|
30
|
+
# rack 2.0 requires ruby 2.2.2, rails 3.2 requires rack ~> 1.4.5
|
31
|
+
gem 'rack', "< 1.5" # REQUIRED
|
32
|
+
|
33
|
+
group :development, :test do
|
34
|
+
if defined?(JRUBY_VERSION)
|
35
|
+
gem 'jruby-openssl'
|
36
|
+
gem 'activerecord-jdbcsqlite3-adapter'
|
37
|
+
else
|
38
|
+
gem 'sqlite3', "~> 1.3.7"
|
39
|
+
end
|
40
|
+
gem 'shoulda', "~> 2.11.0"
|
41
|
+
end
|
data/test/setup_railsapp
CHANGED
@@ -45,9 +45,13 @@ else
|
|
45
45
|
fi
|
46
46
|
|
47
47
|
echo "Running bundle with BUNDLE_GEMFILE=$BUNDLE_GEMFILE ..."
|
48
|
-
if ! bundle ; then
|
48
|
+
if ! bundle install ; then
|
49
49
|
echo "Test aborted (missing required gems)"
|
50
50
|
exit 2
|
51
|
+
else
|
52
|
+
echo bundle passed - lock file contains:
|
53
|
+
cat $BUNDLE_GEMFILE.lock
|
54
|
+
echo
|
51
55
|
fi
|
52
56
|
$rehash
|
53
57
|
|
@@ -74,12 +78,34 @@ actual_rails_version=`$rails -v`
|
|
74
78
|
|
75
79
|
[ -d lib/health_check ] || exec echo setup_railsapp MUST be executed in the base of the health_check gem/clone of git repository
|
76
80
|
|
77
|
-
echo Installing health_check as a gem into tmp/gems
|
78
|
-
env GEM_HOME=$tmp_dir/gems rake install
|
79
|
-
|
80
81
|
export GEM_PATH="$tmp_dir/gems:`gem environment gempath`"
|
81
82
|
echo Set GEM_PATH=$GEM_PATH
|
82
83
|
|
84
|
+
case "$BUNDLE_GEMFILE" in
|
85
|
+
*_lts*)
|
86
|
+
echo "Re-running bundle with changed GEM_PATH (required by git install of rails lts) ..."
|
87
|
+
if ! bundle install ; then
|
88
|
+
echo "Test aborted (missing required gems)"
|
89
|
+
exit 2
|
90
|
+
else
|
91
|
+
echo bundle passed - lock file contains:
|
92
|
+
cat $BUNDLE_GEMFILE.lock
|
93
|
+
echo
|
94
|
+
fi
|
95
|
+
;;
|
96
|
+
esac
|
97
|
+
echo Installing health_check as a gem into $tmp_dir/gems
|
98
|
+
rm -f pkg/health_check-*.gem
|
99
|
+
if env GEM_HOME=$tmp_dir/gems $rake install
|
100
|
+
then
|
101
|
+
echo rake install passed
|
102
|
+
else
|
103
|
+
echo rake install failed! running gem install pkg/health_check-*.gem manually to see error message:
|
104
|
+
env GEM_HOME=$tmp_dir/gems gem install pkg/health_check-*.gem
|
105
|
+
echo gem install worked, but flagging it as a FAIL anyway since rake install failed!
|
106
|
+
exit 2
|
107
|
+
fi
|
108
|
+
|
83
109
|
echo Gems in tmp/gems:
|
84
110
|
ls tmp/gems
|
85
111
|
|
@@ -347,35 +373,18 @@ if [ -s config/routes.rb ]; then
|
|
347
373
|
sed -e '/^end/,$d' config/routes.rb-old
|
348
374
|
fi
|
349
375
|
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
echo " # ---------------------------------------"
|
363
|
-
;;
|
364
|
-
*)
|
365
|
-
# rails 2.3
|
366
|
-
echo " # -----------------------------------------"
|
367
|
-
echo " # START OF SECTION FOR TESTING HEALTH_CHECK"
|
368
|
-
echo " # example controller"
|
369
|
-
echo " ${var}.connect 'example(/:action(/:id))(.:format)', :controller => 'example'"
|
370
|
-
echo " if File.exists?('$catchall_file')"
|
371
|
-
echo " # health_check routes already at the top in rails 2.3! do not need to call health_check_routes"
|
372
|
-
echo " # CATCH ALL ROUTE"
|
373
|
-
echo " ${var}.connect '*path', :controller => 'example', :action => 'catchall'"
|
374
|
-
echo " end"
|
375
|
-
echo " # END OF SECTION FOR TESTING HEALTH_CHECK"
|
376
|
-
echo " # ---------------------------------------"
|
377
|
-
;;
|
378
|
-
esac
|
376
|
+
# rails 2.3
|
377
|
+
echo " # -----------------------------------------"
|
378
|
+
echo " # START OF SECTION FOR TESTING HEALTH_CHECK"
|
379
|
+
echo " # example controller"
|
380
|
+
echo " ${var}.connect 'example(/:action(/:id))(.:format)', :controller => 'example'"
|
381
|
+
echo " if File.exists?('$catchall_file')"
|
382
|
+
echo " # health_check routes already at the top in rails 2.3! do not need to call health_check_routes"
|
383
|
+
echo " # CATCH ALL ROUTE"
|
384
|
+
echo " ${var}.connect '*path', :controller => 'example', :action => 'catchall'"
|
385
|
+
echo " end"
|
386
|
+
echo " # END OF SECTION FOR TESTING HEALTH_CHECK"
|
387
|
+
echo " # ---------------------------------------"
|
379
388
|
ruby -n -e 'print if /^end/..9999' config/routes.rb-old | tee /tmp/t$$
|
380
389
|
if [ ! -s /tmp/t$$ ]; then
|
381
390
|
echo "WARNING: ruby -n -e failed silently - using sed instead!! (rbx-19mode has that problem)" >&3
|
metadata
CHANGED
@@ -1,70 +1,103 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: health_check
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 13
|
5
5
|
prerelease:
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 6
|
9
|
+
- 1
|
10
|
+
version: 1.6.1
|
6
11
|
platform: ruby
|
7
|
-
authors:
|
12
|
+
authors:
|
8
13
|
- Ian Heggie
|
9
14
|
autorequire:
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
|
-
|
17
|
+
|
18
|
+
date: 2016-09-29 00:00:00 +10:00
|
13
19
|
default_executable:
|
14
|
-
dependencies:
|
15
|
-
- !ruby/object:Gem::Dependency
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
16
22
|
name: rails
|
17
|
-
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
18
25
|
none: false
|
19
|
-
requirements:
|
20
|
-
- -
|
21
|
-
- !ruby/object:Gem::Version
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 2
|
32
|
+
- 3
|
33
|
+
- 0
|
22
34
|
version: 2.3.0
|
23
35
|
type: :runtime
|
24
|
-
|
25
|
-
|
26
|
-
- !ruby/object:Gem::Dependency
|
36
|
+
version_requirements: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
27
38
|
name: rake
|
28
|
-
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
29
41
|
none: false
|
30
|
-
requirements:
|
31
|
-
- -
|
32
|
-
- !ruby/object:Gem::Version
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
hash: 57
|
46
|
+
segments:
|
47
|
+
- 0
|
48
|
+
- 8
|
49
|
+
- 3
|
33
50
|
version: 0.8.3
|
51
|
+
- - <
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
hash: 39
|
54
|
+
segments:
|
55
|
+
- 11
|
56
|
+
- 0
|
57
|
+
version: "11.0"
|
34
58
|
type: :development
|
35
|
-
|
36
|
-
|
37
|
-
- !ruby/object:Gem::Dependency
|
59
|
+
version_requirements: *id002
|
60
|
+
- !ruby/object:Gem::Dependency
|
38
61
|
name: shoulda
|
39
|
-
|
62
|
+
prerelease: false
|
63
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
40
64
|
none: false
|
41
|
-
requirements:
|
65
|
+
requirements:
|
42
66
|
- - ~>
|
43
|
-
- !ruby/object:Gem::Version
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
hash: 35
|
69
|
+
segments:
|
70
|
+
- 2
|
71
|
+
- 11
|
72
|
+
- 0
|
44
73
|
version: 2.11.0
|
45
74
|
type: :development
|
46
|
-
|
47
|
-
|
48
|
-
- !ruby/object:Gem::Dependency
|
75
|
+
version_requirements: *id003
|
76
|
+
- !ruby/object:Gem::Dependency
|
49
77
|
name: bundler
|
50
|
-
|
78
|
+
prerelease: false
|
79
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
51
80
|
none: false
|
52
|
-
requirements:
|
81
|
+
requirements:
|
53
82
|
- - ~>
|
54
|
-
- !ruby/object:Gem::Version
|
55
|
-
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
hash: 11
|
85
|
+
segments:
|
86
|
+
- 1
|
87
|
+
- 2
|
88
|
+
version: "1.2"
|
56
89
|
type: :development
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
NewRelic, EngineYard or uptime.openacs.org etc.\n"
|
61
|
-
email:
|
90
|
+
version_requirements: *id004
|
91
|
+
description: " \tSimple health check of Rails app for uptime monitoring with Pingdom, NewRelic, EngineYard or uptime.openacs.org etc.\n"
|
92
|
+
email:
|
62
93
|
- ian@heggie.biz
|
63
94
|
executables: []
|
95
|
+
|
64
96
|
extensions: []
|
65
|
-
|
97
|
+
|
98
|
+
extra_rdoc_files:
|
66
99
|
- README.rdoc
|
67
|
-
files:
|
100
|
+
files:
|
68
101
|
- .document
|
69
102
|
- .gitignore
|
70
103
|
- .travis.yml
|
@@ -91,9 +124,7 @@ files:
|
|
91
124
|
- test/migrate/twelve/012_create_users.rb
|
92
125
|
- test/migrate/twelve/9_create_countries.rb
|
93
126
|
- test/rails_2.3.gemfile
|
94
|
-
- test/
|
95
|
-
- test/rails_3.1.gemfile
|
96
|
-
- test/rails_3.2.gemfile
|
127
|
+
- test/rails_2.3_lts.gemfile
|
97
128
|
- test/setup_railsapp
|
98
129
|
- test/test_helper.rb
|
99
130
|
- test/test_with_railsapp
|
@@ -103,30 +134,38 @@ files:
|
|
103
134
|
has_rdoc: true
|
104
135
|
homepage: https://github.com/ianheggie/health_check
|
105
136
|
licenses: []
|
137
|
+
|
106
138
|
post_install_message:
|
107
139
|
rdoc_options: []
|
108
|
-
|
140
|
+
|
141
|
+
require_paths:
|
109
142
|
- lib
|
110
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
143
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
111
144
|
none: false
|
112
|
-
requirements:
|
113
|
-
- -
|
114
|
-
- !ruby/object:Gem::Version
|
115
|
-
|
116
|
-
|
145
|
+
requirements:
|
146
|
+
- - ">="
|
147
|
+
- !ruby/object:Gem::Version
|
148
|
+
hash: 3
|
149
|
+
segments:
|
150
|
+
- 0
|
151
|
+
version: "0"
|
152
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
153
|
none: false
|
118
|
-
requirements:
|
119
|
-
- -
|
120
|
-
- !ruby/object:Gem::Version
|
121
|
-
|
154
|
+
requirements:
|
155
|
+
- - ">="
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
hash: 3
|
158
|
+
segments:
|
159
|
+
- 0
|
160
|
+
version: "0"
|
122
161
|
requirements: []
|
162
|
+
|
123
163
|
rubyforge_project:
|
124
|
-
rubygems_version: 1.
|
164
|
+
rubygems_version: 1.6.2
|
125
165
|
signing_key:
|
126
166
|
specification_version: 3
|
127
|
-
summary: Simple health check of Rails app for uptime monitoring with Pingdom, NewRelic,
|
128
|
-
|
129
|
-
test_files:
|
167
|
+
summary: Simple health check of Rails app for uptime monitoring with Pingdom, NewRelic, EngineYard or uptime.openacs.org etc.
|
168
|
+
test_files:
|
130
169
|
- test/fake_smtp_server
|
131
170
|
- test/init_variables
|
132
171
|
- test/migrate/empty/do_not_remove.txt
|
@@ -135,9 +174,7 @@ test_files:
|
|
135
174
|
- test/migrate/twelve/012_create_users.rb
|
136
175
|
- test/migrate/twelve/9_create_countries.rb
|
137
176
|
- test/rails_2.3.gemfile
|
138
|
-
- test/
|
139
|
-
- test/rails_3.1.gemfile
|
140
|
-
- test/rails_3.2.gemfile
|
177
|
+
- test/rails_2.3_lts.gemfile
|
141
178
|
- test/setup_railsapp
|
142
179
|
- test/test_helper.rb
|
143
180
|
- test/test_with_railsapp
|
data/test/rails_3.0.gemfile
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
# Gemfile for health_test testing
|
2
|
-
|
3
|
-
source 'https://rubygems.org'
|
4
|
-
|
5
|
-
gem 'rails', "~> 3.0.19"
|
6
|
-
gem 'rake', '>= 0.8.3'
|
7
|
-
|
8
|
-
group :development, :test do
|
9
|
-
if defined?(JRUBY_VERSION)
|
10
|
-
gem 'jruby-openssl'
|
11
|
-
gem 'activerecord-jdbcsqlite3-adapter'
|
12
|
-
else
|
13
|
-
gem 'sqlite3', "~> 1.3.7"
|
14
|
-
end
|
15
|
-
gem 'shoulda', "~> 2.11.0"
|
16
|
-
end
|
data/test/rails_3.1.gemfile
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
# Gemfile for health_test testing
|
2
|
-
|
3
|
-
source 'https://rubygems.org'
|
4
|
-
|
5
|
-
gem 'rails', "~> 3.1.0"
|
6
|
-
gem 'rake', '>= 0.8.3'
|
7
|
-
|
8
|
-
|
9
|
-
group :development, :test do
|
10
|
-
if defined?(JRUBY_VERSION)
|
11
|
-
gem 'jruby-openssl'
|
12
|
-
gem 'activerecord-jdbcsqlite3-adapter'
|
13
|
-
else
|
14
|
-
gem 'sqlite3', "~> 1.3.7"
|
15
|
-
end
|
16
|
-
gem 'shoulda', "~> 2.11.0"
|
17
|
-
end
|
18
|
-
|
19
|
-
# next version requires ruby 1.9.3
|
20
|
-
gem 'i18n', '~> 0.6.11' if RUBY_VERSION < '1.9.3' # REQUIRED
|
21
|
-
|
22
|
-
# Initial Gemfile has therubyracer commented out
|
23
|
-
gem 'therubyrhino', :platform => :jruby # REQUIRED
|
24
|
-
gem 'therubyracer', :platform => :ruby # REQUIRED
|
data/test/rails_3.2.gemfile
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
# Gemfile for health_test testing
|
2
|
-
|
3
|
-
source 'https://rubygems.org'
|
4
|
-
|
5
|
-
gem 'rails', "~> 3.2.0"
|
6
|
-
gem 'rake', '>= 0.8.3'
|
7
|
-
|
8
|
-
group :development, :test do
|
9
|
-
if defined?(JRUBY_VERSION)
|
10
|
-
gem 'jruby-openssl'
|
11
|
-
gem 'activerecord-jdbcsqlite3-adapter'
|
12
|
-
else
|
13
|
-
gem 'sqlite3', "~> 1.3.7"
|
14
|
-
end
|
15
|
-
gem 'shoulda', "~> 2.11.0"
|
16
|
-
end
|
17
|
-
|
18
|
-
# next version requires ruby 1.9.3
|
19
|
-
gem 'i18n', '~> 0.6.11' if RUBY_VERSION < '1.9.3' # REQUIRED
|
20
|
-
|
21
|
-
# Initial Gemfile has therubyracer commented out
|
22
|
-
gem 'therubyrhino', :platform => :jruby # REQUIRED
|
23
|
-
gem 'therubyracer', :platform => :ruby # REQUIRED
|