Sha256: ff9a126ba4bf65de1aa36118bb88d438ec411fc762e91061f4cb80c465ce929b

Contents?: true

Size: 665 Bytes

Versions: 2

Compression:

Stored size: 665 Bytes

Contents

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

    # used for tes
    def get_total_memory
      @cluster.get_total_memory
    end

    def reap(wait_between_worker_kill = 60) # seconds
      return false unless @cluster.running?
      @cluster.workers.each do |worker, ram|
        @cluster.master.log "PumaWorkerKiller: Rolling Restart. #{@cluster.workers.count} workers consuming total: #{ get_total_memory } mb out of max: #{@max_ram} mb. Sending TERM to #{worker.inspect}"
        worker.term
        sleep wait_between_worker_kill
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
puma_worker_killer-0.0.5 lib/puma_worker_killer/rolling_restart.rb
puma_worker_killer-0.0.4 lib/puma_worker_killer/rolling_restart.rb