Class: Webify::Backend::Thin

Inherits:
Object
  • Object
show all
Defined in:
lib/webify/backend/thin.rb

Class Method Summary collapse

Class Method Details

.start!(options = {}) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/webify/backend/thin.rb', line 12

def self.start!(options={})
  dir  = File.expand_path(options[:dir] || Webify::DEFAULT_DIR)
  port = options[:port] || Webify::DEFAULT_PORT
  
  server = ::Thin::Server.new('0.0.0.0', port) do
    use Rack::CommonLogger
    run Rack::Static.new(nil, { :urls => ['/'], :root => dir })
  end
  
  trap('INT') { server.stop! }
  
  Dir.chdir(dir)
  server.start!
end