Sha256: 389124495c9896c9bab4a724ffeb2e736ed83caf25cb48d423f97146521e7389

Contents?: true

Size: 639 Bytes

Versions: 3

Compression:

Stored size: 639 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. Sending TERM to pid #{worker.pid}."
        worker.term
        sleep wait_between_worker_kill
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
gitlab-puma_worker_killer-0.1.1.gitlab.1 lib/puma_worker_killer/rolling_restart.rb
puma_worker_killer-0.1.1 lib/puma_worker_killer/rolling_restart.rb
puma_worker_killer-0.1.0 lib/puma_worker_killer/rolling_restart.rb