Class: Proxy

Inherits:
Object
  • Object
show all
Defined in:
lib/em-proxy/proxy.rb

Class Method Summary collapse

Class Method Details

.start(options, &blk) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/em-proxy/proxy.rb', line 3

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

.stopObject



17
18
19
20
# File 'lib/em-proxy/proxy.rb', line 17

def self.stop
  puts "Terminating ProxyServer"
  EventMachine.stop
end