Class: PumaAutoTune::Master
- Inherits:
-
Object
- Object
- PumaAutoTune::Master
- Defined in:
- lib/puma_auto_tune/master.rb
Instance Method Summary collapse
- #add_worker ⇒ Object
- #get_memory ⇒ Object
-
#initialize(master = nil) ⇒ Master
constructor
A new instance of Master.
- #memory ⇒ Object (also: #mb)
- #remove_worker ⇒ Object
- #running? ⇒ Boolean
-
#send_signal(signal, pid = Process.pid) ⇒ Object
less cryptic interface.
- #workers ⇒ Object
Constructor Details
#initialize(master = nil) ⇒ Master
Returns a new instance of Master.
3 4 5 |
# File 'lib/puma_auto_tune/master.rb', line 3 def initialize(master = nil) @master = master || get_master end |
Instance Method Details
#add_worker ⇒ Object
17 18 19 |
# File 'lib/puma_auto_tune/master.rb', line 17 def add_worker send_signal("TTIN") end |
#get_memory ⇒ Object
31 32 33 |
# File 'lib/puma_auto_tune/master.rb', line 31 def get_memory @memory = ::GetProcessMem.new(Process.pid).mb end |
#memory ⇒ Object Also known as: mb
26 27 28 |
# File 'lib/puma_auto_tune/master.rb', line 26 def memory @memory end |
#remove_worker ⇒ Object
12 13 14 |
# File 'lib/puma_auto_tune/master.rb', line 12 def remove_worker send_signal("TTOU") end |
#running? ⇒ Boolean
7 8 9 |
# File 'lib/puma_auto_tune/master.rb', line 7 def running? @master && workers.any? end |
#send_signal(signal, pid = Process.pid) ⇒ Object
less cryptic interface
22 23 24 |
# File 'lib/puma_auto_tune/master.rb', line 22 def send_signal(signal, pid = Process.pid) Process.kill(signal, pid) end |
#workers ⇒ Object
35 36 37 |
# File 'lib/puma_auto_tune/master.rb', line 35 def workers @master.instance_variable_get("@workers").map {|w| PumaAutoTune::Worker.new(w) } end |