Class: WebSystem::ThinServerRack::ThinHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/web_system/sub/rack/server_racks/thin_server_rack.rb

Overview

NOTE: I don’t know why the file below is not included in the gem. github.com/macournoyer/thin/blob/master/lib/rack/handler/thin.rb

Class Method Summary collapse

Class Method Details

.run(app, **options) {|server| ... } ⇒ Object

Yields:

  • (server)


31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/web_system/sub/rack/server_racks/thin_server_rack.rb', line 31

def self.run(app, **options)
  environment  = ENV['RACK_ENV'] || 'development'
  default_host = environment == 'development' ? 'localhost' : '0.0.0.0'

  host = options.delete(:Host) || default_host
  port = options.delete(:Port) || 3000
  args = [host, port, app, options]

  server = ::Thin::Server.new(*args)
  yield server if block_given?

  server.start
end

.valid_optionsObject



45
46
47
48
49
50
51
52
53
# File 'lib/web_system/sub/rack/server_racks/thin_server_rack.rb', line 45

def self.valid_options
  environment  = ENV['RACK_ENV'] || 'development'
  default_host = environment == 'development' ? 'localhost' : '0.0.0.0'

  {
    "Host=HOST" => "Hostname to listen on (default: #{default_host})",
    "Port=PORT" => "Port to listen on (default: 3000)",
  }
end