Sha256: cddca6b92c7748648ef02e800fbccd2e2cbe9ca6a3f99540381b8ddd32dc9205

Contents?: true

Size: 666 Bytes

Versions: 2

Compression:

Stored size: 666 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 pid #{worker.pid}."
        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.7 lib/puma_worker_killer/rolling_restart.rb
puma_worker_killer-0.0.6 lib/puma_worker_killer/rolling_restart.rb