Skip to content

Commit

Permalink
back to instance_eval to allow unbind
Browse files Browse the repository at this point in the history
  • Loading branch information
igrigorik committed Oct 3, 2010
1 parent 8d7c5e7 commit c445bd5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
6 changes: 3 additions & 3 deletions examples/appserver.rb
@@ -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]})
42 changes: 21 additions & 21 deletions lib/em-proxy/proxy.rb
@@ -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.