Class: Zeus::Server::Stage

Inherits:
ForkedProcess show all
Defined in:
lib/zeus/server/stage.rb

Overview

NONE of the code in the module is run in the master process, so every communication to the master must be done with IPC.

Instance Attribute Summary collapse

Attributes inherited from ForkedProcess

#name, #pid

Instance Method Summary collapse

Methods inherited from ForkedProcess

#before_setup, #initialize, #newly_loaded_features, #notify_feature, #notify_new_features, #notify_started, #notify_terminated, #run, #setup_forked_process

Constructor Details

This class inherits a constructor from Zeus::Server::ForkedProcess

Instance Attribute Details

#actionsObject

Returns the value of attribute actions.



6
7
8
# File 'lib/zeus/server/stage.rb', line 6

def actions
  @actions
end

#stagesObject

Returns the value of attribute stages.



6
7
8
# File 'lib/zeus/server/stage.rb', line 6

def stages
  @stages
end

Instance Method Details

#after_notifyObject



21
22
23
24
25
26
# File 'lib/zeus/server/stage.rb', line 21

def after_notify
  @pids = {}
  @stages.each do |stage|
    @pids[stage.run] = stage
  end
end

#after_setupObject



13
14
15
16
17
18
19
# File 'lib/zeus/server/stage.rb', line 13

def after_setup
  begin
    @actions.each(&:call)
  rescue => e
    handle_load_error(e)
  end
end

#descendent_acceptorsObject



8
9
10
# File 'lib/zeus/server/stage.rb', line 8

def descendent_acceptors
  @stages.map(&:descendent_acceptors).flatten
end

#runloop!Object



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/zeus/server/stage.rb', line 28

def runloop!
  loop do
    begin
      pid = Process.wait
    rescue Errno::ECHILD
      sleep # if this is a terminal node, just let acceptors run...
    end
    stage = @pids[pid]
    @pids[stage.run] = stage
  end
end