Module: Unicorn::WorkerKiller::MaxRequests::MonkeyPatch

Defined in:
lib/unicorn/worker-killer-2/max_requests.rb

Instance Method Summary collapse

Instance Method Details

#process_client(client) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/unicorn/worker-killer-2/max_requests.rb', line 7

def process_client(client)
  super(client) # Unicorn::HttpServer#process_client

  return if @_worker_max_requests_min.zero? &&
            @_worker_max_requests_max.zero?

  logger.info "#{self}: worker (pid: #{Process.pid}) has #{@_worker_request_limit} left before being killed" if @_verbose

  @_worker_request_limit -= 1
  return if @_worker_request_limit.positive?

  logger.warn "#{self}: worker (pid: #{Process.pid}) exceeds max number of requests (limit: #{@_worker_max_requests})"
  WorkerKiller.kill_self(logger, @_worker_process_start)
end