Class: PumaWorkerKiller::PumaMemory
- Inherits:
-
Object
- Object
- PumaWorkerKiller::PumaMemory
- Defined in:
- lib/puma_worker_killer/puma_memory.rb
Instance Attribute Summary collapse
-
#master ⇒ Object
readonly
Returns the value of attribute master.
Instance Method Summary collapse
-
#get_total(workers = set_workers) ⇒ Object
(also: #get_total_memory)
Will refresh @workers.
-
#initialize(master = nil) ⇒ PumaMemory
constructor
A new instance of PumaMemory.
- #largest_worker ⇒ Object
- #largest_worker_memory ⇒ Object
- #running? ⇒ Boolean
- #size ⇒ Object
- #smallest_worker ⇒ Object
- #smallest_worker_memory ⇒ Object
- #term_largest_worker ⇒ Object
- #term_worker(worker) ⇒ Object
- #workers ⇒ Object
- #workers_stopped? ⇒ Boolean
Constructor Details
#initialize(master = nil) ⇒ PumaMemory
Returns a new instance of PumaMemory.
5 6 7 8 |
# File 'lib/puma_worker_killer/puma_memory.rb', line 5 def initialize(master = nil) @master = master || get_master @workers = nil end |
Instance Attribute Details
#master ⇒ Object (readonly)
Returns the value of attribute master.
10 11 12 |
# File 'lib/puma_worker_killer/puma_memory.rb', line 10 def master @master end |
Instance Method Details
#get_total(workers = set_workers) ⇒ Object Also known as: get_total_memory
Will refresh @workers
53 54 55 56 57 |
# File 'lib/puma_worker_killer/puma_memory.rb', line 53 def get_total(workers = set_workers) master_memory = GetProcessMem.new(Process.pid).mb worker_memory = workers.values.inject(:+) || 0 worker_memory + master_memory end |
#largest_worker ⇒ Object
42 43 44 45 |
# File 'lib/puma_worker_killer/puma_memory.rb', line 42 def largest_worker largest_worker, = workers.to_a.last largest_worker end |
#largest_worker_memory ⇒ Object
47 48 49 50 |
# File 'lib/puma_worker_killer/puma_memory.rb', line 47 def largest_worker_memory _, largest_memory_used = workers.to_a.last largest_memory_used end |
#running? ⇒ Boolean
28 29 30 |
# File 'lib/puma_worker_killer/puma_memory.rb', line 28 def running? @master && workers.any? end |
#size ⇒ Object
12 13 14 |
# File 'lib/puma_worker_killer/puma_memory.rb', line 12 def size workers.size end |
#smallest_worker ⇒ Object
32 33 34 35 |
# File 'lib/puma_worker_killer/puma_memory.rb', line 32 def smallest_worker smallest, = workers.to_a.first smallest end |
#smallest_worker_memory ⇒ Object
37 38 39 40 |
# File 'lib/puma_worker_killer/puma_memory.rb', line 37 def smallest_worker_memory _, smallest_mem = workers.to_a.first smallest_mem end |
#term_largest_worker ⇒ Object
20 21 22 |
# File 'lib/puma_worker_killer/puma_memory.rb', line 20 def term_largest_worker largest_worker.term end |
#term_worker(worker) ⇒ Object
16 17 18 |
# File 'lib/puma_worker_killer/puma_memory.rb', line 16 def term_worker(worker) worker.term end |
#workers ⇒ Object
60 61 62 |
# File 'lib/puma_worker_killer/puma_memory.rb', line 60 def workers @workers || set_workers end |
#workers_stopped? ⇒ Boolean
24 25 26 |
# File 'lib/puma_worker_killer/puma_memory.rb', line 24 def workers_stopped? !running? end |