Class: Webify::Backend::Webrick

Inherits:
Object
  • Object
show all
Includes:
WEBrick
Defined in:
lib/webify/backend/webrick.rb

Class Method Summary collapse

Class Method Details

.start!(options = {}) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/webify/backend/webrick.rb', line 24

def self.start!(options={})
  dir  = File.expand_path(options[:dir] || Webify::DEFAULT_DIR)
  port = options[:port] || Webify::DEFAULT_PORT

  server = HTTPServer.new(
    :Port            => port,
    :DocumentRoot    => dir
  )

  server.mount "/", WebrickNoCacheFileHandler, "./"

  trap('INT') { server.shutdown }
  server.start
end