Class: Lattice::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/lattice/server.rb

Instance Method Summary collapse

Constructor Details

#initialize(host, port, options = {}) ⇒ Server

Returns a new instance of Server.



7
8
9
10
11
# File 'lib/lattice/server.rb', line 7

def initialize(host, port, options = {})
  @host, @port = host, port
  @root = options[:root] || Lattice.root
  load
end

Instance Method Details

#loadObject



13
14
15
16
# File 'lib/lattice/server.rb', line 13

def load
  $LOAD_PATH << @root
  require 'config/application'
end

#runObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/lattice/server.rb', line 18

def run
  app = Lattice.app

  app.configure do |config|
    config.ip      = @host
    config.port    = @port
    config.adapter = :Reel
  end

  Lattice.logger.info "A Reel good HTTP server! (Codename \"#{::Reel::CODENAME}\")"
  Lattice.logger.info "Listening on http://#{@host}:#{@port}"

  app.run
end