Class: PumaWorkerKiller::RollingRestart
- Inherits:
-
Object
- Object
- PumaWorkerKiller::RollingRestart
- Defined in:
- lib/puma_worker_killer/rolling_restart.rb
Instance Method Summary collapse
-
#get_total_memory ⇒ Object
used for tes.
-
#initialize(master = nil, rolling_pre_term = nil) ⇒ RollingRestart
constructor
A new instance of RollingRestart.
- #reap(seconds_between_worker_kill = 60) ⇒ Object
Constructor Details
#initialize(master = nil, rolling_pre_term = nil) ⇒ RollingRestart
Returns a new instance of RollingRestart.
5 6 7 8 |
# File 'lib/puma_worker_killer/rolling_restart.rb', line 5 def initialize(master = nil, rolling_pre_term = nil) @cluster = PumaWorkerKiller::PumaMemory.new(master) @rolling_pre_term = rolling_pre_term end |
Instance Method Details
#get_total_memory ⇒ Object
used for tes
11 12 13 |
# File 'lib/puma_worker_killer/rolling_restart.rb', line 11 def get_total_memory @cluster.get_total_memory end |
#reap(seconds_between_worker_kill = 60) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/puma_worker_killer/rolling_restart.rb', line 15 def reap(seconds_between_worker_kill = 60) # this will implicitly call set_workers total_memory = get_total_memory return false unless @cluster.running? @cluster.workers.each do |worker, _ram| @cluster.master.log "PumaWorkerKiller: Rolling Restart. #{@cluster.workers.count} workers consuming total: #{total_memory} mb. Sending TERM to pid #{worker.pid}." @rolling_pre_term&.call(worker) worker.term sleep seconds_between_worker_kill end end |