health_check 0.2.4 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -1,4 +1,4 @@
1
- Copyright (c) 2010 Ian Heggie
1
+ Copyright (c) 2010-2013 Ian Heggie
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
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, wasitup.com or newrelic.com
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 being launched and that it has access to correctly configured resources (database, email gateway)
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
- specify full or include email in the list of checks or varify the smtp settings
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 Plugin
27
+ *As a Gem from rubygems (Rails 3.0 and above)*
28
28
 
29
- % cd vendor/plugins
30
- % git clone git://github.com/ianheggie/health_check.git
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 gemcutter
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
- # Add the following line to config/environment.rb
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
- * [WasItUp](http://wasitup.com/)
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 database contains the current migration level
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-2011 Ian Heggie, released under the MIT license.
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 or wasitup.com}
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.add_development_dependency "shoulda", ">= 0"
14
- gem.add_development_dependency "sqlite3-ruby", ">= 0"
15
- gem.add_development_dependency 'activerecord', '>= 1.15.4.7794'
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
- require 'rake/testtask'
25
- Rake::TestTask.new(:test) do |test|
26
- test.libs << 'lib' << 'test'
27
- test.pattern = 'test/**/test_*.rb'
28
- test.verbose = true
29
- end
30
-
31
- begin
32
- require 'rcov/rcovtask'
33
- Rcov::RcovTask.new do |test|
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
- rescue LoadError
39
- task :rcov do
40
- abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
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
- task :test => :check_dependencies
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
- require 'rake/rdoctask'
49
- Rake::RDocTask.new do |rdoc|
50
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
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
- rdoc.rdoc_dir = 'rdoc'
53
- rdoc.title = "health_check #{version}"
54
- rdoc.rdoc_files.include('README*')
55
- rdoc.rdoc_files.include('lib/**/*.rb')
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.2.4
1
+ 1.0.1
data/config/routes.rb CHANGED
@@ -1,13 +1,6 @@
1
- if defined?(Rails) and Rails.respond_to?(:version) && Rails.version =~ /^3/
2
- if defined? Rails31
3
- Rails31::Application.routes.draw do
4
- match 'health_check', :to => 'health_check#index'
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 rakefile, and run the gemspec command
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 = %q{health_check}
8
- s.version = "0.2.4"
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 = %q{2011-11-16}
13
- s.description = %q{Simple health check of Rails app for use with uptime monitoring sites}
14
- s.email = %q{ian@heggie.biz}
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
- ".gitignore",
21
- "MIT-LICENSE",
22
- "README.rdoc",
23
- "Rakefile",
24
- "VERSION",
25
- "health_check.gemspec",
26
- "init.rb",
27
- "config/routes.rb",
28
- "lib/health_check.rb",
29
- "lib/health_check/add_23_routes.rb",
30
- "lib/health_check/add_3x_routes.rb",
31
- "lib/health_check/health_check_class.rb",
32
- "lib/health_check/health_check_controller.rb",
33
- "test/helper.rb",
34
- "test/migrate/empty/do_not_remove.txt",
35
- "test/migrate/twelve/012_create_users.rb",
36
- "test/migrate/twelve/9_create_countries.rb",
37
- "test/test_health_check_controller.rb",
38
- "test/test_routes.rb"
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 = %q{http://github.com/ianheggie/health_check}
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 = %q{1.3.5}
44
- s.summary = %q{Simple health check of Rails app for use with uptime monitoring sites}
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::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
58
- s.add_development_dependency(%q<shoulda>, [">= 0"])
59
- s.add_development_dependency(%q<sqlite3-ruby>, [">= 0"])
60
- s.add_development_dependency(%q<activerecord>, [">= 1.15.4.7794"])
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<shoulda>, [">= 0"])
63
- s.add_dependency(%q<sqlite3-ruby>, [">= 0"])
64
- s.add_dependency(%q<activerecord>, [">= 1.15.4.7794"])
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<shoulda>, [">= 0"])
68
- s.add_dependency(%q<sqlite3-ruby>, [">= 0"])
69
- s.add_dependency(%q<activerecord>, [">= 1.15.4.7794"])
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
- require 'health_check/health_check_class'
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
- if defined?(Rails) and Rails.respond_to?(:version) && Rails.version =~ /^3/
4
- require 'health_check/add_3x_routes'
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