Class: Pakyow::ProcessManager
- Inherits:
-
Object
- Object
- Pakyow::ProcessManager
- Defined in:
- lib/pakyow/process_manager.rb
Instance Method Summary collapse
- #add(process) ⇒ Object
-
#initialize ⇒ ProcessManager
constructor
A new instance of ProcessManager.
- #restart ⇒ Object
- #stop(signal = :INT) ⇒ Object
- #wait ⇒ Object
Constructor Details
#initialize ⇒ ProcessManager
Returns a new instance of ProcessManager.
9 10 11 |
# File 'lib/pakyow/process_manager.rb', line 9 def initialize @group, @processes, @stopped = Process::Group.new, [], false end |
Instance Method Details
#add(process) ⇒ Object
13 14 15 16 17 |
# File 'lib/pakyow/process_manager.rb', line 13 def add(process) process = process.dup run_process(process) @processes << process end |
#restart ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/pakyow/process_manager.rb', line 28 def restart @group.running.each do |pid, forked| if forked.instance_variable_get(:@options)[:restartable] Process.kill(:INT, pid) end end end |
#stop(signal = :INT) ⇒ Object
23 24 25 26 |
# File 'lib/pakyow/process_manager.rb', line 23 def stop(signal = :INT) @stopped = true @group.kill(signal) end |
#wait ⇒ Object
19 20 21 |
# File 'lib/pakyow/process_manager.rb', line 19 def wait @group.wait end |