health-monitor-rails 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -33,7 +33,7 @@ $ gem install health-monitor-rails
33
33
  You can mount this inside your app routes by adding this to config/routes.rb:
34
34
 
35
35
  ```ruby
36
- mount HealthMonitor::Engine => '/health'
36
+ mount HealthMonitor::Engine, at: '/'
37
37
  ```
38
38
 
39
39
  ## Supported service providers
@@ -42,6 +42,7 @@ The following services are currently supported:
42
42
  * Cache
43
43
  * Redis
44
44
  * Sidekiq
45
+ * Resque
45
46
 
46
47
  ## Configuration
47
48
 
@@ -6,9 +6,9 @@ module HealthMonitor
6
6
  def check
7
7
  HealthMonitor.check!
8
8
 
9
- render text: "Healh check has passed: #{Time.now.to_s(:db)}\n"
9
+ render text: "Health check has passed: #{Time.now.to_s(:db)}\n"
10
10
  rescue Exception => e
11
- render text: "Healh check has failed: #{Time.now.to_s(:db)}, error: #{e.message}\n",
11
+ render text: "Health check has failed: #{Time.now.to_s(:db)}, error: #{e.message}\n",
12
12
  :status => :service_unavailable
13
13
  end
14
14
 
@@ -1,5 +1,7 @@
1
1
  module HealthMonitor
2
2
  module Providers
3
+ class CacheException < StandardError; end
4
+
3
5
  class Cache
4
6
  def check!
5
7
  time = Time.now.to_s
@@ -8,6 +10,8 @@ module HealthMonitor
8
10
  fetched = Rails.cache.read(:health)
9
11
 
10
12
  raise "different values (now: #{time}, fetched: #{fetched}" if fetched != time
13
+ rescue Exception => e
14
+ raise CacheException.new(e.message)
11
15
  end
12
16
  end
13
17
  end
@@ -1,14 +1,13 @@
1
1
  module HealthMonitor
2
2
  module Providers
3
- class DBException < StandardError; end
3
+ class DatabaseException < StandardError; end
4
4
 
5
5
  class Database
6
6
  def check!
7
7
  # Check connection to the DB:
8
- query = 'SELECT version FROM schema_migrations'
9
- ActiveRecord::Base.connection.select_value(query).to_i
10
- rescue => e
11
- raise DBException.new(e.message)
8
+ ActiveRecord::Migrator.current_version
9
+ rescue Exception => e
10
+ raise DatabaseException.new(e.message)
12
11
  end
13
12
  end
14
13
  end
@@ -0,0 +1,15 @@
1
+ require 'resque'
2
+
3
+ module HealthMonitor
4
+ module Providers
5
+ class ResqueException < StandardError; end
6
+
7
+ class Resque
8
+ def check!
9
+ ::Resque.info
10
+ rescue Exception => e
11
+ raise ResqueException.new(e.message)
12
+ end
13
+ end
14
+ end
15
+ end
@@ -7,7 +7,7 @@ module HealthMonitor
7
7
  class Sidekiq
8
8
  def check!
9
9
  ::Sidekiq::Workers.new.size
10
- rescue => e
10
+ rescue Exception => e
11
11
  raise SidekiqException.new(e.message)
12
12
  end
13
13
  end
@@ -1,3 +1,3 @@
1
1
  module HealthMonitor
2
- VERSION = '0.0.4'
2
+ VERSION = '0.0.5'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: health-monitor-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-02-09 00:00:00.000000000 Z
12
+ date: 2014-02-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -171,6 +171,22 @@ dependencies:
171
171
  - - ! '>='
172
172
  - !ruby/object:Gem::Version
173
173
  version: '0'
174
+ - !ruby/object:Gem::Dependency
175
+ name: resque
176
+ requirement: !ruby/object:Gem::Requirement
177
+ none: false
178
+ requirements:
179
+ - - ! '>='
180
+ - !ruby/object:Gem::Version
181
+ version: '0'
182
+ type: :development
183
+ prerelease: false
184
+ version_requirements: !ruby/object:Gem::Requirement
185
+ none: false
186
+ requirements:
187
+ - - ! '>='
188
+ - !ruby/object:Gem::Version
189
+ version: '0'
174
190
  description: Health monitoring Rails plug-in, which checks various services (db, cache,
175
191
  sidekiq, redis, etc.).
176
192
  email:
@@ -188,6 +204,7 @@ files:
188
204
  - lib/health_monitor/providers/cache.rb
189
205
  - lib/health_monitor/providers/database.rb
190
206
  - lib/health_monitor/providers/redis.rb
207
+ - lib/health_monitor/providers/resque.rb
191
208
  - lib/health_monitor/providers/sidekiq.rb
192
209
  - lib/health_monitor/version.rb
193
210
  - Rakefile
@@ -207,7 +224,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
207
224
  version: '0'
208
225
  segments:
209
226
  - 0
210
- hash: 3575176881406320082
227
+ hash: 3257561467928893271
211
228
  required_rubygems_version: !ruby/object:Gem::Requirement
212
229
  none: false
213
230
  requirements:
@@ -216,7 +233,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
216
233
  version: '0'
217
234
  segments:
218
235
  - 0
219
- hash: 3575176881406320082
236
+ hash: 3257561467928893271
220
237
  requirements: []
221
238
  rubyforge_project:
222
239
  rubygems_version: 1.8.25