Class: Rack::Heartbeat
- Inherits:
-
Object
- Object
- Rack::Heartbeat
- Defined in:
- lib/rack/heartbeat.rb
Overview
A heartbeat mechanism for the server. This will add a /heartbeat endpoint that returns status 200 and content OK when executed.
Defined Under Namespace
Classes: Railtie
Constant Summary collapse
- @@heartbeat_path =
'heartbeat'
Class Method Summary collapse
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ Heartbeat
constructor
A new instance of Heartbeat.
Constructor Details
#initialize(app) ⇒ Heartbeat
Returns a new instance of Heartbeat.
9 10 11 |
# File 'lib/rack/heartbeat.rb', line 9 def initialize(app) @app = app end |
Class Method Details
.setup {|_self| ... } ⇒ Object
22 23 24 |
# File 'lib/rack/heartbeat.rb', line 22 def self.setup yield self end |
Instance Method Details
#call(env) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/rack/heartbeat.rb', line 13 def call(env) if env['PATH_INFO'] == "/#{heartbeat_path}" NewRelic::Agent.ignore_transaction if defined? NewRelic [200, {"Content-Type" => "text/plain"}, ["OK"]] else @app.call(env) end end |