Class: Rack::Handler::RightSpeed

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/handler/right_speed.rb

Class Method Summary collapse

Class Method Details

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

Yields:

  • (server)


8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/rack/handler/right_speed.rb', line 8

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

  host = options.delete(:Host) || default_host
  port = options.delete(:Port) || 8080
  workers = options.delete(:Workers) || ::RightSpeed::Env.processors
  server = ::RightSpeed::Server.new(app: app, host: host, port: port, workers: workers)

  yield server if block_given?

  server.run
end

.valid_optionsObject



22
23
24
25
26
27
28
29
30
# File 'lib/rack/handler/right_speed.rb', line 22

def self.valid_options
  environment  = ENV['RACK_ENV'] || 'development'
  default_host = environment == 'development' ? '127.0.0.1' : '0.0.0.0'
  {
    "Host=HOST" => "Hostname to listen on (default: #{default_host})",
    "Port=PORT" => "Port to listen on (default: 8080)",
    "Workers=NUM" => "Number of workers (default: #{::RightSpeed::Env.processors})",
  }
end