Sha256: a835989f44e5bac1f398ef5f665a7c7dd71c860e055ab36453f2f46d7e161ae8

Contents?: true

Size: 811 Bytes

Versions: 4

Compression:

Stored size: 811 Bytes

Contents

module PumaWorkerKiller
  class Reaper
    def initialize(max_ram, master = nil)
      @cluster = PumaWorkerKiller::PumaMemory.new(master)
      @max_ram = max_ram
    end

    # used for tes
    def get_total_memory
      @cluster.get_total_memory
    end

    def reap
      return false unless @cluster.running?
      if (total = get_total_memory) > @max_ram
        @cluster.master.log "PumaWorkerKiller: Out of memory. #{@cluster.workers.count} workers consuming total: #{total} mb out of max: #{@max_ram} mb. Sending TERM to #{@cluster.largest_worker.inspect} consuming #{@cluster.largest_worker_memory} mb."
        @cluster.term_largest_worker
      else
        @cluster.master.log "PumaWorkerKiller: Consuming #{total} mb with master and #{@cluster.workers.count} workers"
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
puma_worker_killer-0.0.5 lib/puma_worker_killer/reaper.rb
puma_worker_killer-0.0.4 lib/puma_worker_killer/reaper.rb
puma_worker_killer-0.0.3 lib/puma_worker_killer/reaper.rb
puma_worker_killer-0.0.2 lib/puma_worker_killer/reaper.rb