Class: Waitress::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/waitress/configure.rb

Overview

The Configuration Class is the object that contains a configuration of a single server instance, hosting all the methods provided by Waitress.configure!

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(configure, *ports) ⇒ Configuration

Returns a new instance of Configuration.



90
91
92
93
94
95
96
97
98
# File 'lib/waitress/configure.rb', line 90

def initialize configure, *ports
  @ports = *ports
  @hosts = []
  @configure = configure
  @internal_error = false

  @processes = 5
  @processes = ENV["WAITRESS_PROCESSES"].to_i if ENV.include? "WAITRESS_PROCESSES"
end

Instance Attribute Details

#hostsObject

Returns the value of attribute hosts.



85
86
87
# File 'lib/waitress/configure.rb', line 85

def hosts
  @hosts
end

#internal_errorObject

Returns the value of attribute internal_error.



88
89
90
# File 'lib/waitress/configure.rb', line 88

def internal_error
  @internal_error
end

#portsObject

Returns the value of attribute ports.



86
87
88
# File 'lib/waitress/configure.rb', line 86

def ports
  @ports
end

#processesObject

Returns the value of attribute processes.



87
88
89
# File 'lib/waitress/configure.rb', line 87

def processes
  @processes
end

Instance Method Details

#all_hosts(&block) ⇒ Object

Over all the registered VHosts, call this method. Use this to configure a similar setting for all vhosts at once instead of duplicating code across all of them.



113
114
115
# File 'lib/waitress/configure.rb', line 113

def all_hosts &block
  @hosts.each { |h| block.call(h) }
end

#detailed_500(enabled) ⇒ Object

Set to true to enable 500 error backtraces in the browser



124
125
126
# File 'lib/waitress/configure.rb', line 124

def detailed_500 enabled
  @internal_error = enabled
end

#host(regex, priority = 50, &block) ⇒ Object

Create a new VirtualHost with the given regex, priority, and configure it inside of its own block.



102
103
104
105
106
107
108
# File 'lib/waitress/configure.rb', line 102

def host regex, priority=50, &block
  host = Waitress::Vhost.new regex, priority
  host.set_configure @configure
  block.call(host)
  @hosts << host
  host
end

#less_watch(time) ⇒ Object

Set the watch period for the LESS Watcher, i.e. how long to sleep before checking LESS files for an update and recompile



119
120
121
# File 'lib/waitress/configure.rb', line 119

def less_watch time
  Waitress::LESSWatcher.set_time time
end

#to_sObject



128
129
130
131
# File 'lib/waitress/configure.rb', line 128

def to_s
  m = lambda { |a,x| x.nil? ? "" : "\r\n#{a}=#{x.inspect}" }
  "#<#{self.class} #{m.call('ports', @ports)} #{m.call('hosts', @hosts)}>"
end