Class: Rackdapter::Proxy
Instance Method Summary
collapse
#apps, #configure, #load_apps
Constructor Details
#initialize(config_path) ⇒ Proxy
Returns a new instance of Proxy.
92
93
94
95
96
|
# File 'lib/rackdapter/proxy.rb', line 92
def initialize(config_path)
configure(config_path)
log "Starting proxy server with configuration at #{config_path}"
start
end
|
Instance Method Details
#config ⇒ Object
76
77
78
|
# File 'lib/rackdapter/proxy.rb', line 76
def config
Rackdapter.config.apps[:proxy]
end
|
#log(message) ⇒ Object
88
89
90
|
# File 'lib/rackdapter/proxy.rb', line 88
def log(message)
logger.info message
end
|
#logger ⇒ Object
80
81
82
83
84
85
86
|
# File 'lib/rackdapter/proxy.rb', line 80
def logger
unless @logger
@logger = Logger.new(config['log'] || STDOUT)
@logger.level = Logger::INFO
end
@logger
end
|
#start ⇒ Object
98
99
100
101
102
103
104
105
106
107
108
109
|
# File 'lib/rackdapter/proxy.rb', line 98
def start
load_apps
EventMachine::run {
apps.each do |name,app|
host,port = "0.0.0.0", app.port
if port && port > 0
log "Starting proxy at #{host}:#{port}"
EventMachine::start_server host, port, InboundProxyConnection, app
end
end
}
end
|