lib/em-proxy/connection.rb in em-proxy-0.1.7 vs lib/em-proxy/connection.rb in em-proxy-0.1.8
- old
+ new
@@ -41,14 +41,23 @@
#
# initialize connections to backend servers
#
def server(name, opts)
- srv = EventMachine::bind_connect(opts[:bind_host], opts[:bind_port], opts[:host], opts[:port], EventMachine::ProxyServer::Backend, @debug) do |c|
- c.name = name
- c.plexer = self
- c.proxy_incoming_to(self, 10240) if opts[:relay_server]
+ if opts[:socket]
+ srv = EventMachine::connect_unix_domain(opts[:socket], EventMachine::ProxyServer::Backend, @debug) do |c|
+ c.name = name
+ c.plexer = self
+ c.proxy_incoming_to(self, 10240) if opts[:relay_server]
+ end
+ else
+ srv = EventMachine::bind_connect(opts[:bind_host], opts[:bind_port], opts[:host], opts[:port], EventMachine::ProxyServer::Backend, @debug) do |c|
+ c.name = name
+ c.plexer = self
+ c.proxy_incoming_to(self, 10240) if opts[:relay_server]
+ end
end
+
self.proxy_incoming_to(srv, 10240) if opts[:relay_client]
@servers[name] = srv
end