Class: PumaAutoTune::Master

Inherits:
Object
  • Object
show all
Defined in:
lib/puma_auto_tune/master.rb

Instance Method Summary collapse

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_workerObject



17
18
19
# File 'lib/puma_auto_tune/master.rb', line 17

def add_worker
  send_signal("TTIN")
end

#get_memoryObject



31
32
33
# File 'lib/puma_auto_tune/master.rb', line 31

def get_memory
  @memory = ::GetProcessMem.new(Process.pid).mb
end

#memoryObject Also known as: mb



26
27
28
# File 'lib/puma_auto_tune/master.rb', line 26

def memory
  @memory
end

#remove_workerObject



12
13
14
# File 'lib/puma_auto_tune/master.rb', line 12

def remove_worker
  send_signal("TTOU")
end

#running?Boolean

Returns:

  • (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

#workersObject



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