health_check 0.2.4 → 1.0.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/Gemfile +18 -0
- data/Gemfile.lock +34 -0
- data/MIT-LICENSE +1 -1
- data/README.rdoc +38 -16
- data/Rakefile +48 -29
- data/VERSION +1 -1
- data/config/routes.rb +4 -11
- data/health_check.gemspec +50 -47
- data/lib/health_check.rb +16 -4
- data/lib/health_check/add_23_routes.rb +5 -2
- data/lib/health_check/health_check_controller.rb +85 -56
- data/lib/health_check/utils.rb +103 -0
- data/test/migrate/nine/9_create_countries.rb +11 -0
- data/test/migrate/twelve/012_create_users.rb +2 -1
- data/test/{helper.rb → test_helper.rb} +0 -1
- data/test/test_with_railsapp +164 -0
- data/test/testurl +33 -0
- data/test/{test_health_check_controller.rb → unit/health_check_controller_test.rb} +31 -31
- data/test/{test_routes.rb → unit/routes_test.rb} +1 -1
- metadata +92 -42
- data/.gitignore +0 -21
- data/lib/health_check/add_3x_routes.rb +0 -13
- data/lib/health_check/health_check_class.rb +0 -99
data/Gemfile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# Gemfile for health_test
|
2
|
+
|
3
|
+
source 'https://rubygems.org'
|
4
|
+
|
5
|
+
group :development, :test do
|
6
|
+
gem 'rake', '>= 0.8.3'
|
7
|
+
gem 'jeweler', '~> 1.8.4'
|
8
|
+
gem 'shoulda', "~> 2.11.0"
|
9
|
+
gem 'sqlite3', "~> 1.3.7"
|
10
|
+
gem 'activerecord', ">= 2.3.0"
|
11
|
+
end
|
12
|
+
|
13
|
+
group :misc do
|
14
|
+
# run travis-lint to check .travis.yml
|
15
|
+
gem 'travis-lint'
|
16
|
+
# required to run rake test:plugins
|
17
|
+
gem 'ruby-prof', '>= 0.6.1'
|
18
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
GEM
|
2
|
+
remote: https://rubygems.org/
|
3
|
+
specs:
|
4
|
+
activerecord (2.3.15)
|
5
|
+
activesupport (= 2.3.15)
|
6
|
+
activesupport (2.3.15)
|
7
|
+
git (1.2.5)
|
8
|
+
hashr (0.0.22)
|
9
|
+
jeweler (1.8.4)
|
10
|
+
bundler (~> 1.0)
|
11
|
+
git (>= 1.2.5)
|
12
|
+
rake
|
13
|
+
rdoc
|
14
|
+
json (1.7.6)
|
15
|
+
rake (10.0.3)
|
16
|
+
rdoc (3.12)
|
17
|
+
json (~> 1.4)
|
18
|
+
ruby-prof (0.12.1)
|
19
|
+
shoulda (2.11.3)
|
20
|
+
sqlite3 (1.3.7)
|
21
|
+
travis-lint (1.5.0)
|
22
|
+
hashr (~> 0.0.22)
|
23
|
+
|
24
|
+
PLATFORMS
|
25
|
+
ruby
|
26
|
+
|
27
|
+
DEPENDENCIES
|
28
|
+
activerecord (>= 2.3.0)
|
29
|
+
jeweler (~> 1.8.4)
|
30
|
+
rake (>= 0.8.3)
|
31
|
+
ruby-prof (>= 0.6.1)
|
32
|
+
shoulda (~> 2.11.0)
|
33
|
+
sqlite3 (~> 1.3.7)
|
34
|
+
travis-lint
|
data/MIT-LICENSE
CHANGED
data/README.rdoc
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
= health_check
|
2
2
|
|
3
|
-
Simple health check of Rails app for use with uptime.openacs.org
|
3
|
+
Simple health check of Rails app for use with Pingdom, NewRelic, EngineYard or uptime.openacs.org etc.
|
4
4
|
|
5
|
-
The basic goal is to check that rails is
|
5
|
+
The basic goal is to quickly check that rails is up and running and that it has access to correctly configured resources (database, email gateway)
|
6
6
|
|
7
|
-
The email gateway is not checked unless the smtp settings have been changed
|
8
|
-
|
7
|
+
The email gateway is not checked unless the smtp settings have been changed.
|
8
|
+
Specify full or include email in the list of checks to varify the smtp settings
|
9
9
|
(eg use 127.0.0.1 instead of localhost).
|
10
10
|
|
11
11
|
health_check provides various monitoring URIs
|
@@ -24,30 +24,49 @@ health_check provides various monitoring URIs
|
|
24
24
|
|
25
25
|
== Installation
|
26
26
|
|
27
|
-
As a
|
27
|
+
*As a Gem from rubygems (Rails 3.0 and above)*
|
28
28
|
|
29
|
-
|
30
|
-
|
29
|
+
Add the following line to Gemfile
|
30
|
+
|
31
|
+
gem "health_check"
|
32
|
+
|
33
|
+
Then run
|
34
|
+
|
35
|
+
% bundle
|
31
36
|
|
32
|
-
As a Gem from
|
37
|
+
*As a Gem from rubygems (Rails 2.3)*
|
38
|
+
|
39
|
+
Install the gem using the following command
|
33
40
|
|
34
41
|
% gem install health_check
|
35
|
-
|
42
|
+
|
43
|
+
Then add the following line to config/environment.rb within the config block
|
44
|
+
|
36
45
|
config.gem "health_check"
|
37
46
|
|
47
|
+
*As a Plugin (Rails 2.3.x)*
|
48
|
+
|
49
|
+
Run the following commands from the root of your rails application
|
50
|
+
|
51
|
+
% cd vendor/plugins
|
52
|
+
% git clone git://github.com/ianheggie/health_check.git
|
53
|
+
|
38
54
|
== Uptime Monitoring
|
39
55
|
|
56
|
+
Use a website monitoring service to check the url regularly for the word "success" rather than just a 200 return code.
|
57
|
+
|
40
58
|
See
|
41
|
-
* [
|
42
|
-
* [Uptime by OpenACS](http://uptime.openacs.org/uptime/)
|
43
|
-
* [Engine Yard's guide](http://community-support.engineyard.com/faqs/guides/uptime-monitoring-for-your-rails-application) guide based on fitter_happier plugin includes monit and other setup help
|
59
|
+
* [Pingdom Website Monitoring](https://www.pingdom.com)
|
44
60
|
* [NewRelic Availability Monitoring](http://newrelic.com/docs/features/availability-monitoring-faq)
|
61
|
+
* [Uptime by OpenACS](http://uptime.openacs.org/uptime/)
|
62
|
+
* [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
|
63
|
+
* Any other montoring service that can be set to check for the word success in the test returned from a url
|
45
64
|
|
46
65
|
== Checks
|
47
66
|
|
48
67
|
* standard (default) - site, database and migrations checks are run plus email if settings have been changed
|
49
68
|
* all / full - all checks are run
|
50
|
-
* database - checks that the
|
69
|
+
* database - checks that the current migration level can be read from the database
|
51
70
|
* email - basic check of email - :test returns true, :sendmail checks file is present and executable, :smtp sends HELO command to server and checks response
|
52
71
|
* migration - checks that the database migration level matches that in db/migrations
|
53
72
|
* site - checks rails is running sufficiently to render text
|
@@ -64,13 +83,11 @@ See
|
|
64
83
|
|
65
84
|
== Copyright
|
66
85
|
|
67
|
-
Copyright (c) 2010-
|
86
|
+
Copyright (c) 2010-2013 Ian Heggie, released under the MIT license.
|
68
87
|
See MIT-LICENSE for details.
|
69
88
|
|
70
89
|
== Known Issues
|
71
90
|
|
72
|
-
* Rails 1.x s not currently supported (smtp_settings versus server_settings)
|
73
|
-
* I wasn't able to get tests to work standalone - the gem has to be installed as a plugin for the tests to work
|
74
91
|
* No inline documentation for methods
|
75
92
|
|
76
93
|
* Feedback welcome especially with suggested replacement code and corresponding tests
|
@@ -78,3 +95,8 @@ See MIT-LICENSE for details.
|
|
78
95
|
== Similar projects
|
79
96
|
|
80
97
|
* fitter_happier plugin by atmos - plugin with similar goals, but not compatible with uptime, and does not check email gateway
|
98
|
+
|
99
|
+
== Continuous integration tests
|
100
|
+
|
101
|
+
Travis CI testing result: {<img src="https://travis-ci.org/ianheggie/health_check.png" />}[https://travis-ci.org/ianheggie/health_check]
|
102
|
+
|
data/Rakefile
CHANGED
@@ -5,52 +5,71 @@ begin
|
|
5
5
|
require 'jeweler'
|
6
6
|
Jeweler::Tasks.new do |gem|
|
7
7
|
gem.name = "health_check"
|
8
|
-
gem.summary = %Q{Simple health check of Rails app}
|
9
|
-
gem.description = %Q{Simple health check of Rails app for use with uptime.openacs.org
|
8
|
+
gem.summary = %Q{Simple health check of Rails app for uptime monitoring}
|
9
|
+
gem.description = %Q{Simple health check of Rails app for use with Pingdom, NewRelic, EngineYard or uptime.openacs.org etc.}
|
10
10
|
gem.email = "ian@heggie.biz"
|
11
11
|
gem.homepage = "http://github.com/ianheggie/health_check"
|
12
12
|
gem.authors = ["Ian Heggie"]
|
13
|
-
gem
|
14
|
-
gem.add_development_dependency
|
15
|
-
gem.
|
13
|
+
# Gemfile contains gem dependencies, apart from bundler itself
|
14
|
+
gem.add_development_dependency 'bundler', '~> 1.2.0'
|
15
|
+
gem.files.exclude 'gemfiles/*', '.travis.yml'
|
16
16
|
|
17
17
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
18
18
|
end
|
19
19
|
Jeweler::GemcutterTasks.new
|
20
|
+
|
21
|
+
#task :test => :check_dependencies
|
20
22
|
rescue LoadError
|
21
23
|
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
22
24
|
end
|
23
25
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
test
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
test.libs << 'test'
|
35
|
-
test.pattern = 'test/**/test_*.rb'
|
26
|
+
# Tests are conducted with health_test as a plugin
|
27
|
+
environment_file = File.join(File.dirname(__FILE__), '..', '..', '..', 'config', 'environment.rb')
|
28
|
+
plugin_dir = File.join(File.dirname(__FILE__), '..', 'plugins')
|
29
|
+
if File.exists?(environment_file) and File.directory?(plugin_dir)
|
30
|
+
# test as plugin
|
31
|
+
|
32
|
+
require 'rake/testtask'
|
33
|
+
Rake::TestTask.new(:test) do |test|
|
34
|
+
test.libs << 'lib' << 'test'
|
35
|
+
test.pattern = 'test/**/*_test.rb'
|
36
36
|
test.verbose = true
|
37
37
|
end
|
38
|
-
|
39
|
-
|
40
|
-
|
38
|
+
|
39
|
+
begin
|
40
|
+
require 'rcov/rcovtask'
|
41
|
+
Rcov::RcovTask.new do |test|
|
42
|
+
test.libs << 'test'
|
43
|
+
test.pattern = 'test/**/*_test.rb'
|
44
|
+
test.verbose = true
|
45
|
+
end
|
46
|
+
rescue LoadError
|
47
|
+
task :rcov do
|
48
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
49
|
+
end
|
41
50
|
end
|
42
|
-
end
|
43
51
|
|
44
|
-
|
52
|
+
else
|
53
|
+
#tests as gem
|
54
|
+
task :test do
|
55
|
+
exec '/bin/bash', './test/test_with_railsapp'
|
56
|
+
end
|
57
|
+
end
|
45
58
|
|
46
59
|
task :default => :test
|
47
60
|
|
48
|
-
|
49
|
-
|
50
|
-
|
61
|
+
begin
|
62
|
+
gem 'rdoc'
|
63
|
+
require 'rdoc/task'
|
64
|
+
|
65
|
+
Rake::RDocTask.new do |rdoc|
|
66
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
51
67
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
68
|
+
rdoc.rdoc_dir = 'rdoc'
|
69
|
+
rdoc.title = "health_check #{version}"
|
70
|
+
rdoc.rdoc_files.include('README*')
|
71
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
72
|
+
end
|
73
|
+
rescue Gem::LoadError
|
74
|
+
puts "rdoc (or a dependency) not available. Install it with: gem install rdoc"
|
56
75
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
1.0.1
|
data/config/routes.rb
CHANGED
@@ -1,13 +1,6 @@
|
|
1
|
-
if defined?(
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
match 'health_check/:checks', :to => 'health_check#check'
|
6
|
-
end
|
7
|
-
else
|
8
|
-
Rails.application.routes.draw do |map|
|
9
|
-
match 'health_check', :to => 'health_check#index'
|
10
|
-
match 'health_check/:checks', :to => 'health_check#check'
|
11
|
-
end
|
1
|
+
if defined?(HealthCheck::Engine)
|
2
|
+
Rails.application.routes.draw do
|
3
|
+
match 'health_check', :to => 'health_check/health_check#index'
|
4
|
+
match 'health_check/:checks', :to => 'health_check/health_check#check'
|
12
5
|
end
|
13
6
|
end
|
data/health_check.gemspec
CHANGED
@@ -1,72 +1,75 @@
|
|
1
1
|
# Generated by jeweler
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
|
-
s.name =
|
8
|
-
s.version = "0.
|
7
|
+
s.name = "health_check"
|
8
|
+
s.version = "1.0.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Ian Heggie"]
|
12
|
-
s.date =
|
13
|
-
s.description =
|
14
|
-
s.email =
|
12
|
+
s.date = "2013-01-23"
|
13
|
+
s.description = "Simple health check of Rails app for use with Pingdom, NewRelic, EngineYard or uptime.openacs.org etc."
|
14
|
+
s.email = "ian@heggie.biz"
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"README.rdoc"
|
17
17
|
]
|
18
18
|
s.files = [
|
19
19
|
".document",
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
20
|
+
"Gemfile",
|
21
|
+
"Gemfile.lock",
|
22
|
+
"MIT-LICENSE",
|
23
|
+
"README.rdoc",
|
24
|
+
"Rakefile",
|
25
|
+
"VERSION",
|
26
|
+
"config/routes.rb",
|
27
|
+
"health_check.gemspec",
|
28
|
+
"init.rb",
|
29
|
+
"lib/health_check.rb",
|
30
|
+
"lib/health_check/add_23_routes.rb",
|
31
|
+
"lib/health_check/health_check_controller.rb",
|
32
|
+
"lib/health_check/utils.rb",
|
33
|
+
"test/migrate/empty/do_not_remove.txt",
|
34
|
+
"test/migrate/nine/9_create_countries.rb",
|
35
|
+
"test/migrate/twelve/012_create_users.rb",
|
36
|
+
"test/migrate/twelve/9_create_countries.rb",
|
37
|
+
"test/test_helper.rb",
|
38
|
+
"test/test_with_railsapp",
|
39
|
+
"test/testurl",
|
40
|
+
"test/unit/health_check_controller_test.rb",
|
41
|
+
"test/unit/routes_test.rb"
|
39
42
|
]
|
40
|
-
s.homepage =
|
41
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
43
|
+
s.homepage = "http://github.com/ianheggie/health_check"
|
42
44
|
s.require_paths = ["lib"]
|
43
|
-
s.rubygems_version =
|
44
|
-
s.summary =
|
45
|
-
s.test_files = [
|
46
|
-
"test/helper.rb",
|
47
|
-
"test/migrate/twelve/012_create_users.rb",
|
48
|
-
"test/migrate/twelve/9_create_countries.rb",
|
49
|
-
"test/test_health_check_controller.rb",
|
50
|
-
"test/test_routes.rb"
|
51
|
-
]
|
45
|
+
s.rubygems_version = "1.8.24"
|
46
|
+
s.summary = "Simple health check of Rails app for uptime monitoring"
|
52
47
|
|
53
48
|
if s.respond_to? :specification_version then
|
54
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
55
49
|
s.specification_version = 3
|
56
50
|
|
57
|
-
if Gem::Version.new(Gem::
|
58
|
-
s.add_development_dependency(%q<
|
59
|
-
s.add_development_dependency(%q<
|
60
|
-
s.add_development_dependency(%q<
|
51
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
52
|
+
s.add_development_dependency(%q<rake>, [">= 0.8.3"])
|
53
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
|
54
|
+
s.add_development_dependency(%q<shoulda>, ["~> 2.11.0"])
|
55
|
+
s.add_development_dependency(%q<sqlite3>, ["~> 1.3.7"])
|
56
|
+
s.add_development_dependency(%q<activerecord>, [">= 2.3.0"])
|
57
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.2.0"])
|
61
58
|
else
|
62
|
-
s.add_dependency(%q<
|
63
|
-
s.add_dependency(%q<
|
64
|
-
s.add_dependency(%q<
|
59
|
+
s.add_dependency(%q<rake>, [">= 0.8.3"])
|
60
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
|
61
|
+
s.add_dependency(%q<shoulda>, ["~> 2.11.0"])
|
62
|
+
s.add_dependency(%q<sqlite3>, ["~> 1.3.7"])
|
63
|
+
s.add_dependency(%q<activerecord>, [">= 2.3.0"])
|
64
|
+
s.add_dependency(%q<bundler>, ["~> 1.2.0"])
|
65
65
|
end
|
66
66
|
else
|
67
|
-
s.add_dependency(%q<
|
68
|
-
s.add_dependency(%q<
|
69
|
-
s.add_dependency(%q<
|
67
|
+
s.add_dependency(%q<rake>, [">= 0.8.3"])
|
68
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
|
69
|
+
s.add_dependency(%q<shoulda>, ["~> 2.11.0"])
|
70
|
+
s.add_dependency(%q<sqlite3>, ["~> 1.3.7"])
|
71
|
+
s.add_dependency(%q<activerecord>, [">= 2.3.0"])
|
72
|
+
s.add_dependency(%q<bundler>, ["~> 1.2.0"])
|
70
73
|
end
|
71
74
|
end
|
72
75
|
|
data/lib/health_check.rb
CHANGED
@@ -1,8 +1,20 @@
|
|
1
|
-
|
1
|
+
# Copyright (c) 2010-2013 Ian Heggie, released under the MIT license.
|
2
|
+
# See MIT-LICENSE for details.
|
3
|
+
|
4
|
+
module HealthCheck
|
5
|
+
|
6
|
+
if Rails.version >= '3.0'
|
7
|
+
class Engine < Rails::Engine
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
12
|
+
|
13
|
+
require 'health_check/utils'
|
2
14
|
require 'health_check/health_check_controller'
|
3
|
-
|
4
|
-
|
5
|
-
else
|
15
|
+
|
16
|
+
unless defined?(HealthCheck::Engine)
|
6
17
|
require 'health_check/add_23_routes'
|
7
18
|
end
|
8
19
|
|
20
|
+
# vi: sw=2 sm ai:
|
@@ -1,3 +1,6 @@
|
|
1
|
+
# Copyright (c) 2010-2013 Ian Heggie, released under the MIT license.
|
2
|
+
# See MIT-LICENSE for details.
|
3
|
+
|
1
4
|
# rails prior to 3.0
|
2
5
|
module ActionController
|
3
6
|
module Routing #:nodoc:
|
@@ -6,9 +9,9 @@ module ActionController
|
|
6
9
|
def draw
|
7
10
|
draw_without_health_check_routes do |map|
|
8
11
|
map.connect 'health_check',
|
9
|
-
:controller => 'health_check', :action => 'index'
|
12
|
+
:controller => 'health_check/health_check', :action => 'index'
|
10
13
|
map.connect 'health_check/:checks',
|
11
|
-
:controller => 'health_check', :action => 'check'
|
14
|
+
:controller => 'health_check/health_check', :action => 'check'
|
12
15
|
yield map
|
13
16
|
end
|
14
17
|
end
|