Permalink
Browse files

back to instance_eval to allow unbind

  • Loading branch information...
igrigorik committed Oct 3, 2010
1 parent 8d7c5e7 commit c445bd51c6a9ac351e4fffa4cf1905447018811e
Showing with 24 additions and 24 deletions.
  1. +3 −3 examples/appserver.rb
  2. +21 −21 lib/em-proxy/proxy.rb
View
@@ -1,11 +1,11 @@
require "rubygems"
require "rack"
-app = lambda {
+app = Proc.new do
p [:serving, ARGV[0]]
- sleep(ARGV[1].to_i)
+ sleep(ARGV[1].to_i)
[200, {"Content-Type" => "text/plain"}, ["hello world: #{ARGV[1]}"]]
-}
+end
Rack::Handler::Mongrel.run(app, {:Host => "0.0.0.0", :Port => ARGV[0]})
View
@@ -1,21 +1,21 @@
-class Proxy
-
- def self.start(options, &blk)
- EM.epoll
- EM.run do
-
- trap("TERM") { stop }
- trap("INT") { stop }
-
- EventMachine::start_server(options[:host], options[:port],
- EventMachine::ProxyServer::Connection, options) do |c|
- blk.call(c)
- end
- end
- end
-
- def self.stop
- puts "Terminating ProxyServer"
- EventMachine.stop
- end
-end
+class Proxy
+
+ def self.start(options, &blk)
+ EM.epoll
+ EM.run do
+
+ trap("TERM") { stop }
+ trap("INT") { stop }
+
+ EventMachine::start_server(options[:host], options[:port],
+ EventMachine::ProxyServer::Connection, options) do |c|
+ c.instance_eval(&blk)
+ end
+ end
+ end
+
+ def self.stop
+ puts "Terminating ProxyServer"
+ EventMachine.stop
+ end
+end

0 comments on commit c445bd5

Please sign in to comment.