Class: Listener

Inherits:
GServer show all
Defined in:
lib/listener.rb

Constant Summary collapse

DEFAULT_PORT =
'8084'
DEFAULT_IP =
'127.0.0.1'

Instance Method Summary collapse

Constructor Details

#initialize(application_class_name, config) ⇒ Listener

:nodoc:



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/listener.rb', line 8

def initialize(application_class_name, config) #:nodoc:
  @application_class_name = application_class_name
  @logger = FreecLogger.new(dev_or_test? ? STDOUT : @@log_file)
  @logger.level = Logger::INFO unless dev_or_test?
  @config = config
  host = @config['listen_ip'] || DEFAULT_IP
  port = @config['listen_port'] || DEFAULT_PORT
  super(port.to_i, host, (1.0/0.0))
  self.audit = true
  connect_to_database
end

Instance Method Details

#serve(io) ⇒ Object

:nodoc:



20
21
22
23
24
25
26
# File 'lib/listener.rb', line 20

def serve(io) #:nodoc:
  app = Kernel.const_get(@application_class_name).new(io, @logger, @config)
  app.handle_call
rescue StandardError => e
  @logger.error e.message
  e.backtrace.each {|trace_line| @logger.error(trace_line)}    
end