Permalink
Browse files

Added in EventMachine support, but EM has some serious bugs.

  • Loading branch information...
Don Werve
Don Werve committed Mar 14, 2010
1 parent bebf2ba commit 2c4ef81401767711f5694680fe7c6220e2fde8cc
Showing with 20 additions and 0 deletions.
  1. +20 −0 lib/rack/handler/jetty.rb
View
@@ -4,6 +4,7 @@
require 'java'
require 'rack'
+require 'eventmachine'
# Load Jetty JARs.
jars = %w(cometd-api-1.0.0rc0.jar
@@ -38,6 +39,9 @@ class Rack::Handler::Jetty
include_class 'org.eclipse.jetty.server.nio.SelectChannelConnector'
def self.run(app, options = {})
+ # Block until the EventMachine reactor is running.
+# start_event_machine
+
# The Jetty server
server = Server.new
@@ -66,6 +70,22 @@ def self.run(app, options = {})
puts "Started Jetty on #{connector.getHost}:#{connector.getPort}"
server.start
end
+
+ private
+
+ def self.start_event_machine
+ puts "Starting reactor..."
+ queue = Queue.new
+ Thread.new do
+ EventMachine::run do
+ EventMachine::next_tick { queue.push('done!') }
+ EventMachine::add_periodic_timer(10) { puts "ding!" }
+ end
+ end
+ queue.pop
+ sleep(3)
+ puts "started!"
+ end
end
# Register ourselves with Rack when this file gets loaded.

0 comments on commit 2c4ef81

Please sign in to comment.