Class: Riser::DRbServiceServer
- Inherits:
-
Object
- Object
- Riser::DRbServiceServer
- Extended by:
- Forwardable
- Defined in:
- lib/riser/services.rb
Instance Method Summary collapse
- #add_druby_process(uri, config = {}) ⇒ Object
-
#detach ⇒ Object
for forked child process.
-
#initialize ⇒ DRbServiceServer
constructor
A new instance of DRbServiceServer.
- #start ⇒ Object
- #stop ⇒ Object
- #wait ⇒ Object
Constructor Details
#initialize ⇒ DRbServiceServer
Returns a new instance of DRbServiceServer.
85 86 87 88 |
# File 'lib/riser/services.rb', line 85 def initialize @front = DRbServiceFront.new @druby_process_list = [] end |
Instance Method Details
#add_druby_process(uri, config = {}) ⇒ Object
92 93 94 95 |
# File 'lib/riser/services.rb', line 92 def add_druby_process(uri, config={}) @druby_process_list << DRbProcess.new(uri, config) nil end |
#detach ⇒ Object
for forked child process
121 122 123 124 125 126 127 |
# File 'lib/riser/services.rb', line 121 def detach for drb_process in @druby_process_list drb_process.latch_write_io.close end nil end |
#start ⇒ Object
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/riser/services.rb', line 97 def start @druby_process_list.each_with_index do |drb_process, pos| latch_read_io, latch_write_io = IO.pipe pid = Process.fork{ latch_write_io.close pos.times do |i| @druby_process_list[i].latch_write_io.close end @front.apply_at_fork @front.apply_service_hooks{ DRb.start_service(drb_process.uri, @front, drb_process.config) while (latch_read_io.gets) # wait end } } latch_read_io.close drb_process.latch_write_io = latch_write_io drb_process.pid = pid end nil end |
#stop ⇒ Object
137 138 139 140 |
# File 'lib/riser/services.rb', line 137 def stop detach wait end |
#wait ⇒ Object
129 130 131 132 133 134 135 |
# File 'lib/riser/services.rb', line 129 def wait for drb_process in @druby_process_list Process.waitpid(drb_process.pid) end nil end |