Sha256: c4dd8c1236ff195aa6762fa6dcd6db4b35eefbf8c1a7c49fbb85d942e15ab306
Contents?: true
Size: 1.84 KB
Versions: 4
Compression:
Stored size: 1.84 KB
Contents
worker_processes 4 # assuming four CPU cores preload_app true Rainbows! do use :EventMachine, :em_client_class => lambda{ RainbowsEventMachineThreadPoolClient # or # RainbowsEventMachineFiberSpawnClient } worker_connections 100 client_max_body_size 20*1024*1024 # 20 megabytes client_header_buffer_size 8*1024 # 8 kilobytes end after_fork{ |_, _| EM.threadpool_size = 32 class RainbowsEventMachineThreadPoolClient < Rainbows::EventMachine::Client def app_call input set_comm_inactivity_timeout 0 @env[RACK_INPUT] = input @env[REMOTE_ADDR] = @_io.kgio_addr @env[ASYNC_CALLBACK] = method(:write_async_response) @env[ASYNC_CLOSE] = EM::DefaultDeferrable.new @deferred = true EM.defer{ status, headers, body = catch(:async) { APP.call(@env.merge!(RACK_DEFAULTS)) } if nil == status || -1 == status @deferred = true else @deferred = nil ev_write_response(status, headers, body, @hp.next?) end } end end class RainbowsEventMachineFiberSpawnClient < Rainbows::EventMachine::Client def app_call input set_comm_inactivity_timeout 0 @env[RACK_INPUT] = input @env[REMOTE_ADDR] = @_io.kgio_addr @env[ASYNC_CALLBACK] = method(:write_async_response) @env[ASYNC_CLOSE] = EM::DefaultDeferrable.new f = Fiber.new{ status, headers, body = catch(:async) { APP.call(@env.merge!(RACK_DEFAULTS)) } if nil == status || -1 == status @deferred = true else @deferred = nil ev_write_response(status, headers, body, @hp.next?) end } f.resume @deferred = true if f.alive? end end } EM.error_handler{ |e| puts "Error: EM.error_handler: #{e.inspect} #{e.backtrace.inspect}" }
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
rest-more-2.0.4 | example/rainbows.rb |
rest-more-2.0.3 | example/rainbows.rb |
rest-more-2.0.2 | example/rainbows.rb |
rest-more-2.0.0 | example/rainbows.rb |