rails_health_check 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: ece3b0c5fed38d6c9ccc1e60600284733553b5ae6caa8eaa40f4da34b1cf0339
4
+ data.tar.gz: 146bc1328a9f22300105500be926fe1d3cb982ae0f7410cfc725fa961e66062c
5
+ SHA512:
6
+ metadata.gz: 8cd5439d276daf70a246f73d17df6fc5768881360018a488b5804149ddee18d384da602aaa99080f7ac715517a86bd83f3425165b1e5bd1c3126ae695d72c3f9
7
+ data.tar.gz: e7e76f22b9f8a6fe74d8b3fcbb3e4cc072ea2186cfb55d9b8a0d7a3b89b4b9af6b14a588a7266fe6d5146f11e86a07a0e2e8bc037d364da5b5cd8f5cf19d3396
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,49 @@
1
+ # Suggested by bundler
2
+ *.gem
3
+ *.rbc
4
+ .bundle
5
+ .config
6
+ .yardoc
7
+ Gemfile.lock
8
+ InstalledFiles
9
+ _yardoc
10
+ coverage
11
+ doc/
12
+ lib/bundler/man
13
+ pkg
14
+ rdoc
15
+ spec/reports
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
19
+ .ruby-version
20
+
21
+ ## PROJECT::SPECIFIC
22
+ bin/
23
+ test/bin/
24
+ railsapps/
25
+ test/*.gemfile.lock
26
+ ,*
27
+
28
+ # See: https://gist.github.com/ianheggie/9327010
29
+ # for Global git ignore for OS/IDE/temp/backup files
30
+ .vagrant/
31
+
32
+ ### Vim
33
+ # Swap
34
+ [._]*.s[a-v][a-z]
35
+ [._]*.sw[a-p]
36
+ [._]s[a-rt-v][a-z]
37
+ [._]ss[a-gi-z]
38
+ [._]sw[a-p]
39
+
40
+ # Session
41
+ Session.vim
42
+
43
+ # Temporary
44
+ .netrwhist
45
+ *~
46
+ # Auto-generated tag files
47
+ tags
48
+ # Persistent undo
49
+ [._]*.un~
data/.travis.yml ADDED
@@ -0,0 +1,50 @@
1
+ sudo: false
2
+ addons:
3
+ apt:
4
+ packages:
5
+ - net-tools
6
+
7
+ cache: bundler
8
+ language: ruby
9
+ notifications:
10
+ email:
11
+ on_success: change
12
+ on_failure: always
13
+
14
+ before_install:
15
+ - gem update --system $RUBYGEMS_VERSION
16
+ - gem --version
17
+ - gem install bundler ${BUNDLER_VERSION:+-v} ${BUNDLER_VERSION}
18
+ - gem install smarter_bundler
19
+ - bundle --version
20
+ - mkdir -p tmp/bundle
21
+
22
+ bundler_args: "--binstubs"
23
+
24
+ script: ./test/test_with_railsapp
25
+
26
+ matrix:
27
+ fast_finish: true
28
+
29
+ allow_failures:
30
+ - rvm: 2.4.3
31
+ gemfile: test/rails_edge.gemfile
32
+ env: RAILS_VERSION=edge MIDDLEWARE=YES
33
+
34
+ - rvm: ruby-head
35
+ gemfile: test/rails_5.1.gemfile
36
+ env: RAILS_VERSION=5.1 MIDDLEWARE=YES
37
+
38
+ include:
39
+ - rvm: 2.4.3
40
+ gemfile: test/rails_edge.gemfile
41
+ env: RAILS_VERSION=edge MIDDLEWARE=YES
42
+
43
+ - rvm: ruby-head
44
+ gemfile: test/rails_5.1.gemfile
45
+ env: RAILS_VERSION=5.1 MIDDLEWARE=YES
46
+
47
+ - rvm: 2.3.1
48
+ gemfile: test/rails_5.1.gemfile
49
+ env: RAILS_VERSION=5.1 MIDDLEWARE=YES
50
+
data/CHANGELOG ADDED
@@ -0,0 +1,64 @@
1
+ = Change Log =
2
+
3
+ * 2.7.0
4
+ * Add ability to check health of redis when url is non-standard redis url
5
+ * 2.6.0
6
+ * Add named custom checks
7
+ * 2.5.0
8
+ * Added whitelist for IP# (Thanks Fernando Alvarez)
9
+ * reworked whitelist PR
10
+ * Expanded tests for whitelist and basic authentication
11
+ * reworked middleware, simplified error codes, added whitelist and basic authentication into middleware
12
+ * Removed unit tests as they where aonly applicable under rails 2.3 when installed in vendor/plugins
13
+ * #55 by mnoack - correct binstubs arg in test
14
+ * #54 by gkop - Lograge config snippet works with Rails 4.2.7.1, lograge 0.4.1
15
+ * Used ideas from #52 - use middleware to catch Rails stack exceptions
16
+ * #51 by tokenshift - Fixing NameError on `basic_auth_username`.
17
+ * Changes to address #50 by fillphafftek - allow standard check to be run from middleware if configured to do so, removed requirement for "middleware" to be passed in url for middleware tests
18
+ * 2.4.0
19
+ * Added tests for middleware
20
+ * Changed contributed middleware code to conform to existing url scheme
21
+ * Allow both GET and POST calls
22
+ * Prefer config.uri for changing route prefix
23
+ * 2.3.0
24
+ * Fix route reload issue
25
+ * Various fixes to get tests working with bundle/jruby and other gem issues
26
+ * Document additional branches
27
+ * Fix route reload issue (auto routing previosuly conflicted with devise)
28
+ * Removed ref to rails 2.3, 3.*
29
+
30
+ * 2.2.1
31
+ * Adjust private/public cache-control based on max_age set
32
+ * 2.2.0
33
+ * Add max_age so we can control the caching of responses, don't run tests if Last-modified still matches
34
+ * Added basic auth - Thanks omadahealth
35
+ * A few macinations due to gem changes and avoidning triggering deprecation notices
36
+ * Add single quote to README to make the configuration file valid - Thanks Ryan Selk <ryanselk@gmail.com>
37
+ * Fixed README formatting
38
+ * 2.1.0
39
+ * Updated contributed tests so there is both the forced check and a *-if-present check which tests if the gem's class is loaded
40
+ * Added resque-redis check - Thanks filiphaftek <filip.haftek@airhelp.com>
41
+ * In addition to adding a test file to S3, we will also try to delete it to confirm that delete operations are possible - Thanks Anton Dimitrov <dimitrov.anton@gmail.com>
42
+ * Added redis, sidekiq-redis and s3 health-checks - Thanks Filip <filip.haftek@airhelp.com>
43
+ * Fix render options - Thanks Yuji Hanamura <yuji.developer@gmail.com>
44
+ * Fix to always return a 200 status code on success rather than 304 (adds Last-Modified) - Thanks macgregordennis <macgregordennis@gmail.com>
45
+ * Added Rails 5.0 tests
46
+
47
+ * 2.0.0 - Removed silence - recommend to use a log filtering gem instead
48
+ * 1.4.1 - Rails 4 and route changes
49
+ * Now handles routes being generated multiple times by some gem / rails / ruby combinations - Previously multiple calls to health_check_routes where ignored, now explicit calls to health_check_route always adds the route but flags that it doesn't have to be added again on the end of the list
50
+ * Uses ActiveRecord::Migration.check_pending! if available and returns the message if an exception is raised (Rails 4.0+)
51
+ * Simplified routing rules down to one rule for Rails 3.0+
52
+ * Includes some changes for rails 4.1 (edge) - but still a work in progress
53
+ * 1.3.1 - Include changes from contributers:
54
+ * Migrations with dots are now handled
55
+ * the list of checks for "full" / "all" can be configured
56
+ * 1.2.0 - The gem can now be configured, including timeouts, status codes and text returned on success
57
+ - Customn checks can be added via initializer like config.add_custom_check { CustomCheckClass.a_custom_check }
58
+ - You can now request the response to be json or xml (via url or Content-accepted header)
59
+ - reduced tests to the versions of ruby recomended for the different versions of rails
60
+ * 1.1.2 - Change to bundler support for building gems, as jeweler gem was broken by v2.0.0 of rubygems
61
+ * 1.1.0 - Include cache check (Thanks to https://github.com/mgomes1 ) and some changes to test setup to workaround and diagnose test failures under rvm
62
+ * 1.0.2 - Included travis config and gemfiles used in travis tests in gem and changes to test setup so that gem test
63
+ * 1.x - Includes Rails 3.x suppprt as an Engine
64
+ * 0.x - Rails 2.3
data/Gemfile ADDED
@@ -0,0 +1,20 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in health_check.gemspec
4
+
5
+ gemspec
6
+
7
+ group :development, :test do
8
+ if defined?(JRUBY_VERSION)
9
+ gem 'jruby-openssl'
10
+ gem 'activerecord-jdbcsqlite3-adapter'
11
+ else
12
+ gem 'sqlite3', '~> 1.3.7'
13
+ end
14
+ # run travis-lint to check .travis.yml
15
+ gem 'travis-lint'
16
+ # mime-types 2.0 requires Ruby version >= 1.9.2
17
+ # mime-types 3.0 requires Ruby version >= 2.0
18
+ gem 'mime-types', defined?(JRUBY_VERSION) || RUBY_VERSION < '2.0' ? '< 3' : '>= 3.0'
19
+
20
+ end
data/MIT-LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2010-2013 Ian Heggie
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,337 @@
1
+ = health_check gem
2
+
3
+ Simple health check of Rails edge apps for use with Pingdom, NewRelic, EngineYard or uptime.openacs.org etc.
4
+
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
+
7
+ Use gem versions for stable releases, or github branch / commits for development versions:
8
+ * gem versions ~> 3.0 for Rails 5.x, or the {rails5}[https://github.com/ianheggie/health_check/tree/rails5] development branch
9
+ * gem versions ~> 2.0 for Rails 4.x, or the {rails4}[https://github.com/ianheggie/health_check/tree/rails4] development branch;
10
+ * gem versions ~> 1.7 for Rails 3.x, or the {rails3}[https://github.com/ianheggie/health_check/tree/rails3] development branch;
11
+ * gem versions ~> 1.6.1 for Rails 2.3, or the {rails2.3}[https://github.com/ianheggie/health_check/tree/rails2.3] development branch;
12
+ * {master}[https://github.com/ianheggie/health_check/tree/master] branch for edge development;
13
+
14
+ Note: it is best to pin to a specific commit if using a development branch as sometimes tests break.
15
+
16
+ health_check provides various monitoring URIs, for example:
17
+
18
+ curl localhost:3000/health_check
19
+ success
20
+
21
+ curl localhost:3000/health_check/all.json
22
+ {"healthy":true,"message":"success"}
23
+
24
+ curl localhost:3000/health_check/database_cache_migration.xml
25
+ <?xml version="1.0" encoding="UTF-8"?>
26
+ <hash>
27
+ <healthy type="boolean">true</healthy>
28
+ <message>success</message>
29
+ </hash>
30
+
31
+ You may also issue POST calls instead of GET to these urls.
32
+
33
+ On failure (detected by health_check) a 500 http status is returned with a simple explanation of the failure
34
+
35
+ curl localhost:3000/health_check/fail
36
+ health_check failed: invalid argument to health_test.
37
+
38
+ The health_check controller disables sessions for versions that eagerly load sessions.
39
+
40
+ == Checks
41
+
42
+ * standard (default) - site, database and migrations checks are run plus email if ActionMailer is defined and it is not using the default configuration
43
+ * all / full - all checks are run (can be overriden in config block)
44
+ * cache - checks that a value can be written to the cache
45
+ * custom - runs checks added via config.add_custom_check
46
+ * database - checks that the current migration level can be read from the database
47
+ * email - basic check of email - :test returns true, :sendmail checks file is present and executable, :smtp sends HELO command to server and checks response
48
+ * migration - checks that the database migration level matches that in db/migrations
49
+ * redis / redis-if-present - checks Redis connectivity
50
+ * resque-redis / resque-redis-if-present - checks Resque connectivity to Redis
51
+ * s3 / s3-if-present - checks proper permissions to s3 buckets
52
+ * sidekiq-redis / sidekiq-redis-if-present - checks Sidekiq connectivity to Redis
53
+ * site - checks rails is running sufficiently to render text
54
+
55
+ Some checks have a *-if-present form, which only runs the check if the corresponding library has been required.
56
+
57
+ The email gateway is not checked unless the smtp settings have been changed.
58
+ Specify full or include email in the list of checks to verify the smtp settings
59
+ (eg use 127.0.0.1 instead of localhost).
60
+
61
+ Note: rails 4.0 also checks migrations by default in development mode and throws an ActiveRecord::PendingMigrationError exception (http error 500) if there is an error
62
+
63
+ == Installation
64
+
65
+ Add the following line to Gemfile
66
+
67
+ gem "health_check"
68
+
69
+ And then execute
70
+
71
+ bundle
72
+
73
+ Or install it yourself as:
74
+
75
+ gem install health_check
76
+
77
+ == Configuration
78
+
79
+ To change the configuration of health_check, create a file `config/initializers/health_check.rb` and add a configuration block like:
80
+
81
+ HealthCheck.setup do |config|
82
+
83
+ # uri prefix (no leading slash)
84
+ config.uri = 'health_check'
85
+
86
+ # Text output upon success
87
+ config.success = 'success'
88
+
89
+ # Timeout in seconds used when checking smtp server
90
+ config.smtp_timeout = 30.0
91
+
92
+ # http status code used when plain text error message is output
93
+ # Set to 200 if you want your want to distinguish between partial (text does not include success) and
94
+ # total failure of rails application (http status of 500 etc)
95
+
96
+ config.http_status_for_error_text = 500
97
+
98
+ # http status code used when an error object is output (json or xml)
99
+ # Set to 200 if you want your want to distinguish between partial (healthy property == false) and
100
+ # total failure of rails application (http status of 500 etc)
101
+
102
+ config.http_status_for_error_object = 500
103
+
104
+ # bucket names to test connectivity - required only if s3 check used, access permissions can be mixed
105
+ config.buckets = {'bucket_name' => [:R, :W, :D]}
106
+
107
+ # You can customize which checks happen on a standard health check, eg to set an explicit list use:
108
+ config.standard_checks = [ 'database', 'migrations', 'custom' ]
109
+
110
+ # Or to exclude one check:
111
+ config.standard_checks -= [ 'emailconf' ]
112
+
113
+ # You can set what tests are run with the 'full' or 'all' parameter
114
+ config.full_checks = ['database', 'migrations', 'custom', 'email', 'cache', 'redis', 'resque-redis', 'sidekiq-redis', 's3']
115
+
116
+ # Add one or more custom checks that return a blank string if ok, or an error message if there is an error
117
+ config.add_custom_check do
118
+ CustomHealthCheck.perform_check # any code that returns blank on success and non blank string upon failure
119
+ end
120
+
121
+ # Add another custom check with a name, so you can call just specific custom checks. This can also be run using
122
+ # the standard 'custom' check.
123
+ # You can define multiple tests under the same name - they will be run one after the other.
124
+ config.add_custom_check('sometest') do
125
+ CustomHealthCheck.perform_another_check # any code that returns blank on success and non blank string upon failure
126
+ end
127
+
128
+ # max-age of response in seconds
129
+ # cache-control is public when max_age > 1 and basic_auth_username is not set
130
+ # You can force private without authentication for longer max_age by
131
+ # setting basic_auth_username but not basic_auth_password
132
+ config.max_age = 1
133
+
134
+ # Protect health endpoints with basic auth
135
+ # These default to nil and the endpoint is not protected
136
+ config.basic_auth_username = 'my_username'
137
+ config.basic_auth_password = 'my_password'
138
+
139
+ # Whitelist requesting IPs
140
+ # Defaults to blank and allows any IP
141
+ config.origin_ip_whitelist = %w(123.123.123.123)
142
+
143
+ # http status code used when the ip is not allowed for the request
144
+ config.http_status_for_ip_whitelist_error = 403
145
+
146
+ # When redis url is non-standard
147
+ config.redis_url = 'redis_url'
148
+
149
+ # Disable the error message to prevent /health_check from leaking
150
+ # sensitive information
151
+ config.include_error_in_response_body = false
152
+ end
153
+
154
+ You may call add_custom_check multiple times with different tests. These tests will be included in the default list ("standard").
155
+
156
+ If you have a catchall route then add the following line above the catch all route (in `config/routes.rb`):
157
+ health_check_routes
158
+
159
+ === Installing As Middleware
160
+
161
+ Install health_check as middleware if you want to sometimes ignore exceptions from later parts of the Rails middleware stack,
162
+ eg DB connection errors from QueryCache. The "middleware" check will fail if you have not installed health_check as middleware.
163
+
164
+ To install health_check as middleware add the following line to the config/application.rb:
165
+ config.middleware.insert_after Rails::Rack::Logger, HealthCheck::MiddlewareHealthcheck
166
+
167
+ Note: health_check is installed as a full rails engine even if it has been installed as middleware. This is so the
168
+ remaining checks continue to run through the complete rails stack.
169
+
170
+ You can also adjust what checks are run from middleware, eg if you want to exclude the checking of the database etc, then set
171
+ config.middleware_checks = ['middleware', 'standard', 'custom']
172
+ config.standard_checks = ['middleware', 'custom']
173
+
174
+ Middleware checks are run first, and then full stack checks.
175
+ When installed as middleware, exceptions thrown when running the full stack tests are formatted in the standard way.
176
+
177
+ == Uptime Monitoring
178
+
179
+ Use a website monitoring service to check the url regularly for the word "success" (without the quotes) rather than just a 200 http status so
180
+ that any substitution of a different server or generic information page should also be reported as an error.
181
+
182
+ If an error is encounted, the text "health_check failed: some error message/s" will be returned and the http status will be 500.
183
+
184
+ See
185
+
186
+ * Pingdom Website Monitoring - https://www.pingdom.com
187
+ * NewRelic Availability Monitoring - http://newrelic.com/docs/features/availability-monitoring-faq
188
+ * Uptime by OpenACS - http://uptime.openacs.org/uptime/
189
+ * 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)
190
+ * Nagios check_http (with -s success) - https://www.nagios-plugins.org/doc/man/check_http.html
191
+ * Any other montoring service that can be set to check for the word success in the text returned from a url
192
+
193
+ === Requesting Json and XML responses
194
+
195
+ Health_check will respond with an encoded hash object if json or xml is requested.
196
+ Either set the HTTP Accept header or append .json or .xml to the url.
197
+
198
+ The hash contains two keys:
199
+ * healthy - true if requested checks pass (boolean)
200
+ * message - text message ("success" or error message)
201
+
202
+ The following commands
203
+
204
+ curl -v localhost:3000/health_check.json
205
+ curl -v localhost:3000/health_check/email.json
206
+ curl -v -H "Accept: application/json" localhost:3000/health_check
207
+
208
+ Will return a result with Content-Type: application/json and body like:
209
+
210
+ {"healthy":true,"message":"success"}
211
+
212
+ These following commands
213
+
214
+ curl -v localhost:3000/health_check.xml
215
+ curl -v localhost:3000/health_check/migration_cache.xml
216
+ curl -v -H "Accept: text/xml" localhost:3000/health_check/cache
217
+
218
+ Will return a result with Content-Type: application/xml and body like:
219
+
220
+ <?xml version="1.0" encoding="UTF-8"?>
221
+ <hash>
222
+ <healthy type="boolean">true</healthy>
223
+ <message>success</message>
224
+ </hash>
225
+
226
+ See https://github.com/ianheggie/health_check/wiki/Ajax-Example for an Ajax example
227
+
228
+ == Silencing log output
229
+
230
+ It is recomended that you use silencer, lograge or one of the other log filtering gems.
231
+
232
+ For example, with lograge use the following to exclude health_check from being logged:
233
+
234
+ config.lograge.ignore_actions = ["HealthCheck::HealthCheckController#index"]
235
+
236
+ Likewise you will probably want to exclude health_check from monitoring systems like newrelic.
237
+
238
+ == Caching
239
+
240
+ Cache-control is set with
241
+ * public if max_age is > 1 and basic_auth_username is not set (otherwise private)
242
+ * no-cache
243
+ * must-revalidate
244
+ * max-age (default 1)
245
+
246
+ Last-modified is set to the current time (rounded down to a multiple of max_age when max_age > 1)
247
+
248
+ == Note on Patches/Pull Requests
249
+
250
+ <em>Feedback welcome! Especially with suggested replacement code and corresponding tests</em>
251
+
252
+ 1. Fork it
253
+ 2. Create your feature branch (<tt>git checkout -b my-new-feature</tt>)
254
+ 3. Commit your changes (<tt>git commit -am 'Add some feature'</tt>)
255
+ 4. Push to the branch (<tt>git push origin my-new-feature</tt>)
256
+ 5. Create new Pull Request.
257
+
258
+ == Known Issues
259
+
260
+ * No inline documentation for methods
261
+ * <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)
262
+
263
+ == Similar projects
264
+
265
+ * fitter_happier plugin by atmos - plugin with similar goals, but not compatible with uptime, and does not check email gateway
266
+
267
+ == Testing
268
+
269
+ === Automated testing and other checks
270
+
271
+ * {<img src="https://badge.fury.io/rb/health_check.png" alt="Gem Version" />}[http://badge.fury.io/rb/health_check] - Latest Gem
272
+ * {<img src="https://travis-ci.org/ianheggie/health_check.png">}[https://travis-ci.org/ianheggie/health_check] - Travis CI
273
+ * {<img src="https://codeclimate.com/github/ianheggie/health_check.png" />}[https://codeclimate.com/github/ianheggie/health_check] - Code quality
274
+ * {<img src="https://gemnasium.com/ianheggie/health_check.png">}[https://gemnasium.com/ianheggie/health_check] - Gem dependencies
275
+
276
+ === Manual testing
277
+
278
+ The instructions have been changed to using a vagrant virtual box for consistant results.
279
+
280
+ Install vagrant 1.9.7 or later and virtual_box or other local virtual machine providor.
281
+
282
+ Create a temp directory for throw away testing, and clone the health_check gem into it
283
+
284
+ mkdir -p ~/tmp
285
+ cd ~/tmp
286
+ git clone https://github.com/ianheggie/health_check.git ~/tmp/health_check
287
+
288
+ The Vagrantfile includes provisioning rules to install chruby (ruby version control),
289
+ ruby-build will also be installed and run to build various rubies under /opt/rubies.
290
+
291
+ Use <tt>vagrant ssh</tt> to connect to the virtual box and run tests.
292
+
293
+ The test script will package up and install the gem under a temporary path, create a dummy rails app configured for sqlite,
294
+ install the gem, and then run up tests against the server.
295
+ This will require TCP port 3456 to be free.
296
+
297
+ Cd to the checked out health_check directory and then run the test as follows:
298
+
299
+ cd ~/tmp/health_check
300
+
301
+ vagrant up # this will also run vagrant provision and take some time
302
+ # chruby and various ruby versions will be installed
303
+
304
+ vagrant ssh
305
+
306
+ cd /vagrant # the current directory on your host is mounted here on the virtual machine
307
+
308
+ chruby 2.2.2 # or some other ruby version (run chruby with no arguments to see the current list)
309
+
310
+ test/test_with_railsapp
311
+
312
+ exit # from virtual machine when finished
313
+
314
+ The script will first call `test/setup_railsapp` to setup a rails app with health_check installed and then
315
+ run up the rails server and perform veraious tests.
316
+
317
+ The script `test/setup_railsapp` will prompt you for which gemfile under test you wish to use to install the appropriate rails version, and then
318
+ setup tmp/railsapp accordingly.
319
+
320
+ The command `rake test` will also launch these tests, except it cannot install the bundler and rake gems if they are missing first (unlike test/test_with_railsapp)
321
+
322
+ == Copyright
323
+
324
+ Copyright (c) 2010-2017 Ian Heggie, released under the MIT license.
325
+ See MIT-LICENSE for details.
326
+
327
+ == Contributors
328
+
329
+ Thanks go to the various people who have given feedback and suggestions via the issues list and pull requests.
330
+
331
+ === Contributing
332
+
333
+ 1. Fork it
334
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
335
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
336
+ 4. Push to the branch (`git push origin my-new-feature`)
337
+ 5. Create new Pull Request (Code with BDD tests are favoured)
data/Rakefile ADDED
@@ -0,0 +1,29 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ #require 'rubygems'
4
+ require 'rake'
5
+
6
+ #tests as gem
7
+ task :test do
8
+ exec '/bin/bash', './test/test_with_railsapp'
9
+ end
10
+
11
+ task :default => :test
12
+
13
+ begin
14
+ gem 'rdoc'
15
+ require 'rdoc/task'
16
+
17
+ Rake::RDocTask.new do |rdoc|
18
+ version = HealthCheck::VERSION
19
+
20
+ rdoc.rdoc_dir = 'rdoc'
21
+ rdoc.title = "health_check #{version}"
22
+ rdoc.rdoc_files.include('README*')
23
+ rdoc.rdoc_files.include('CHANGELOG')
24
+ rdoc.rdoc_files.include('MIT-LICENSE')
25
+ rdoc.rdoc_files.include('lib/**/*.rb')
26
+ end
27
+ rescue Gem::LoadError
28
+ puts "rdoc (or a dependency) not available. Install it with: gem install rdoc"
29
+ end
data/Vagrantfile ADDED
@@ -0,0 +1,20 @@
1
+ # -*- mode: ruby -*-
2
+ # vi: set ft=ruby :
3
+
4
+ Vagrant.configure("2") do |config|
5
+ # For a complete reference, please see the online documentation at
6
+ # https://docs.vagrantup.com.
7
+
8
+ config.vm.box = "ubuntu/xenial64"
9
+
10
+ # set auto_update to false, if you do NOT want to check the correct
11
+ # additions version when booting this machine
12
+ config.vbguest.auto_update = false
13
+
14
+ # do NOT download the iso file from a webserver
15
+ config.vbguest.no_remote = true
16
+
17
+ # provision with a shell script.
18
+ config.vm.provision "shell", path: "./test/provision_vagrant"
19
+
20
+ end
data/config/routes.rb ADDED
@@ -0,0 +1,5 @@
1
+ unless HealthCheck::Engine.routes_explicitly_defined
2
+ Rails.application.routes.draw do
3
+ add_health_check_routes()
4
+ end
5
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'health_check/version'
6
+
7
+ Gem::Specification.new do |gem|
8
+ gem.name = 'rails_health_check'
9
+ gem.version = HealthCheck::VERSION
10
+ gem.required_rubygems_version = Gem::Requirement.new('>= 0') if gem.respond_to? :required_rubygems_version=
11
+ gem.authors = ['Ian Heggie']
12
+ gem.email = ['ian@heggie.biz']
13
+ gem.summary = 'Simple health check of Rails app for uptime monitoring with Pingdom, NewRelic, EngineYard or uptime.openacs.org etc.'
14
+ gem.description = <<-EOF
15
+ Fork of https://github.com/ianheggie/health_check.
16
+ Simple health check of Rails app for uptime monitoring with Pingdom, NewRelic, EngineYard or uptime.openacs.org etc.
17
+ EOF
18
+ gem.homepage = 'https://github.com/FinalCAD/health_check'
19
+
20
+ gem.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
21
+ gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
22
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
23
+ gem.extra_rdoc_files = ['README.rdoc']
24
+ gem.require_paths = ['lib']
25
+ gem.required_ruby_version = '>= 2.2.2'
26
+ gem.add_dependency('rails', ['>= 4.0'])
27
+ gem.add_development_dependency('bundler')
28
+ gem.add_development_dependency('rake', ['>= 0.8.3'])
29
+ gem.add_development_dependency('shoulda', ['~> 2.11.0'])
30
+ gem.add_development_dependency('smarter_bundler', ['>= 0.1.0'])
31
+ gem.add_development_dependency 'sqlite3'
32
+ end
data/init.rb ADDED
@@ -0,0 +1,2 @@
1
+ require 'health_check'
2
+
@@ -0,0 +1,5 @@
1
+ module BaseHealthCheck
2
+ def create_error(check_type, error_message)
3
+ "[#{check_type} - #{error_message}] "
4
+ end
5
+ end