Class: UnicornWrangler::OutOfMemoryKiller
- Defined in:
- lib/unicorn_wrangler.rb
Instance Method Summary collapse
- #call(requests, request_time) ⇒ Object
-
#initialize(logger, stats, max: 20, check_every: 250) ⇒ OutOfMemoryKiller
constructor
A new instance of OutOfMemoryKiller.
Constructor Details
#initialize(logger, stats, max: 20, check_every: 250) ⇒ OutOfMemoryKiller
Returns a new instance of OutOfMemoryKiller.
146 147 148 149 150 151 |
# File 'lib/unicorn_wrangler.rb', line 146 def initialize(logger, stats, max: 20, check_every: 250) super(logger, stats) @max = max @check_every = check_every @logger.info "Killing workers when using more than #{@max}MB" end |
Instance Method Details
#call(requests, request_time) ⇒ Object
153 154 155 156 157 158 159 160 161 162 |
# File 'lib/unicorn_wrangler.rb', line 153 def call(requests, request_time) return unless (requests % @check_every).zero? # avoid overhead of checking memory too often memory = used_memory if memory > @max kill :memory, memory, requests, request_time else @stats.histogram("#{STATS_NAMESPACE}.keep.memory", memory) if @stats report_status "Keeping", :memory, memory, requests, request_time end end |