Sha256: 512288eae9d5a0b686a7b264a5fae24b881b402d3192420e5275a46e1a0c850a

Contents?: true

Size: 812 Bytes

Versions: 1

Compression:

Stored size: 812 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 pid #{@cluster.largest_worker.pid} 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

1 entries across 1 versions & 1 rubygems

Version Path
puma_worker_killer-0.0.6 lib/puma_worker_killer/reaper.rb