Parent

Puma::Configuration::DSL

The methods that are available for use inside the config file.

Public Class Methods

new(options) click to toggle source
# File lib/puma/configuration.rb, line 115
def initialize(options)
  @options = options
end

Public Instance Methods

_load_from(path) click to toggle source
# File lib/puma/configuration.rb, line 119
def _load_from(path)
  instance_eval File.read(path), path, 1
end
activate_control_app(url="auto", opts=nil) click to toggle source

Start the Puma control rack app on url. This app can be communicated with to control the main server.

# File lib/puma/configuration.rb, line 137
def activate_control_app(url="auto", opts=nil)
  @options[:control_url] = url

  if opts
    if tok = opts[:auth_token]
      @options[:control_auth_token] = tok
    end

    if opts[:no_token]
      @options[:control_auth_token] = :none
    end
  end
end
app(obj=nil, &block) click to toggle source

Use obj or block as the Rack app. This allows a config file to be the app itself.

# File lib/puma/configuration.rb, line 126
def app(obj=nil, &block)
  obj ||= block

  raise "Provide either a #call'able or a block" unless obj

  @options[:app] = obj
end
bind(url) click to toggle source

Bind the server to url. tcp:// and unix:// are the only accepted protocols.

# File lib/puma/configuration.rb, line 154
def bind(url)
  @options[:binds] << url
end
environment(environment) click to toggle source

Set the environment in which the Rack’s app will run.

# File lib/puma/configuration.rb, line 213
def environment(environment)
  @options[:environment] = environment
end
on_restart(&blk) click to toggle source

Code to run before doing a restart. This code should close logfiles, database connections, etc.

This can be called multiple times to add code each time.

# File lib/puma/configuration.rb, line 163
def on_restart(&blk)
  @options[:on_restart] << blk
end
pidfile(path) click to toggle source

Store the pid of the server in the file at path.

# File lib/puma/configuration.rb, line 168
def pidfile(path)
  @options[:pidfile] = path
end
quiet() click to toggle source

Disable request logging.

# File lib/puma/configuration.rb, line 174
def quiet
  @options[:quiet] = true
end
rackup(path) click to toggle source

Load path as a rackup file.

# File lib/puma/configuration.rb, line 180
def rackup(path)
  @options[:rackup] = path.to_s
end
ssl_bind(host, port, opts) click to toggle source
# File lib/puma/configuration.rb, line 196
def ssl_bind(host, port, opts)
  o = [
    "cert=#{opts[:cert]}",
    "key=#{opts[:key]}"
  ]

  @options[:binds] << "ssl://#{host}:#{port}?#{o.join('&')}"
end
state_path(path) click to toggle source

Use path as the file to store the server info state. This is used by pumactl to query and control the server.

# File lib/puma/configuration.rb, line 208
def state_path(path)
  @options[:state] = path.to_s
end
threads(min, max) click to toggle source

Configure min to be the minimum number of threads to use to answer requests and max the maximum.

# File lib/puma/configuration.rb, line 187
def threads(min, max)
  if min > max
    raise "The minimum number of threads must be less than the max"
  end

  @options[:min_threads] = min
  @options[:max_threads] = max
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.