Class: PulseController
- Inherits:
-
ActionController::Base
- Object
- ActionController::Base
- PulseController
- Defined in:
- lib/pulse/controller.rb
Instance Method Summary collapse
-
#pulse ⇒ Object
The pulse action.
Instance Method Details
#pulse ⇒ Object
The pulse action. Runs select 1
on the DB. If a sane result is returned, ‘OK’ is displayed and a 200 response code is returned. If not, ‘ERROR’ is returned along with a 500 response code.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/pulse/controller.rb', line 7 def pulse adapter = ActiveRecord::Base::connection_pool.spec.config[:adapter] health_method = "#{adapter}_healthy?" # Need to include all methods in respond_to? because Ruby 2.0 returns false # even for protected methods. activerecord_okay = if respond_to?(health_method, true) send(health_method) else raise "Don't know how to check #{adapter}... please to fix?" end if activerecord_okay render :text => okay_response else render :text => error_response, :status => :internal_server_error end end |