Class: UnicornKiller::MaxRequests

Inherits:
Object
  • Object
show all
Includes:
Kill
Defined in:
lib/unicorn_killer.rb

Instance Method Summary collapse

Methods included from Kill

#quit

Constructor Details

#initialize(app, max_requests = 1000) ⇒ MaxRequests


42
43
44
45
# File 'lib/unicorn_killer.rb', line 42

def initialize(app, max_requests = 1000)
  @app = app 
  @max_requests = max_requests
end

Instance Method Details

#call(env) ⇒ Object


47
48
49
50
51
# File 'lib/unicorn_killer.rb', line 47

def call(env)
  @process_start ||= Time.now
  quit if (@max_requests -= 1) == 0
  @app.call env
end