Skip to content

Instantly share code, notes, and snippets.

@romansergey
Last active December 14, 2015 14:49
Show Gist options
  • Save romansergey/5103388 to your computer and use it in GitHub Desktop.
Save romansergey/5103388 to your computer and use it in GitHub Desktop.
@jruby-1.7.2 files to launch reel at see it crash under ab hit
source 'https://rubygems.org'
gem 'celluloid-io', :git => 'https://github.com/celluloid/celluloid-io.git'
gem 'celluloid', :git => 'https://github.com/celluloid/celluloid.git'
gem 'reel',:git => 'https://github.com/celluloid/reel.git'
require 'reel'
require 'test_actor'
class MyServer < Reel::Server
def initialize(host = "127.0.0.1", port = 3000)
@actor_pool = TestActor.pool(size: 2)
# or:
# @actor_pool = TestActor.new
# to reproduce https://github.com/celluloid/celluloid-io/issues/46
super(host, port, &method(:on_connection))
end
def on_connection(connection)
while request = connection.request
case request
when Reel::Request
connection.detach
handle_request(request)
when Reel::WebSocket
handle_websocket(request)
end
end
end
def handle_request(request)
@actor_pool.async.fire do |response|
request.respond :ok, response
end
end
def handle_websocket(sock)
sock << "Hello everyone out there in WebSocket land!"
sock.close
end
end
puts "Starting server..."
MyServer.run
require 'celluloid'
class TestActor
include Celluloid
def fire(&block)
uri = URI('http://localhost/') # Nginx giving out a "Hello world" running on this url
block.call(Net::HTTP.get(uri))
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment