Class: Adelnor::ClusteredServer
- Inherits:
-
BaseServer
- Object
- BaseServer
- Adelnor::ClusteredServer
- Defined in:
- lib/adelnor/clustered_server.rb
Instance Method Summary collapse
- #handle_worker ⇒ Object
-
#initialize(rack_app, port, options = {}) ⇒ ClusteredServer
constructor
A new instance of ClusteredServer.
- #run ⇒ Object
Methods inherited from BaseServer
#handle, #rack_data, #read_request_message, run, #welcome_message
Constructor Details
#initialize(rack_app, port, options = {}) ⇒ ClusteredServer
Returns a new instance of ClusteredServer.
7 8 9 10 11 |
# File 'lib/adelnor/clustered_server.rb', line 7 def initialize(rack_app, port, = {}) super(rack_app, port, ) @workers = [:workers] end |
Instance Method Details
#handle_worker ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/adelnor/clustered_server.rb', line 21 def handle_worker pid = Process.pid puts "[#{pid}] Worker started" loop do client, = @socket.accept handle(client) client.close end end |
#run ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/adelnor/clustered_server.rb', line 13 def run @workers.times do fork { handle_worker } end Process.waitall end |