Class: PulseController

Inherits:
ActionController::Base
  • Object
show all
Defined in:
lib/pulse_controller.rb

Instance Method Summary collapse

Instance Method Details

#loggerObject

cancel out loggin for the PulseController by defining logger as nil



22
23
24
# File 'lib/pulse_controller.rb', line 22

def logger
  nil
end

#pulseObject

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.



10
11
12
13
14
15
16
17
18
19
# File 'lib/pulse_controller.rb', line 10

def pulse
  if (ActiveRecord::Base::connection_pool.spec.adapter_method =~ /mysql2/) &&
    ((ActiveRecord::Base.connection.execute("select 1 from dual").count rescue 0) == 1)
    render :text => "<html><body>OK  #{Time.now.utc.to_s(:db)}</body></html>"
  elsif (ActiveRecord::Base.connection.execute("select 1 from dual").num_rows rescue 0) == 1
    render :text => "<html><body>OK  #{Time.now.utc.to_s(:db)}</body></html>"
  else
    render :text => '<html><body>ERROR</body></html>', :status => :internal_server_error
  end
end