Class: Rage::Configuration::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/rage/configuration.rb

Instance Attribute Summary collapse

Instance Attribute Details

#max_clientsInteger

Note:

Decreasing this number is almost never a good idea. Depending on your application specifics, you are encouraged to use other methods to limit the number of concurrent connections:

Limit the number of simultaneous connections the server can accept. Defaults to the maximum number of open files.

Examples:

Limit the amount of connections your application can accept

Rage.configure do
  config.middleware.use Rack::Attack
  Rack::Attack.throttle("req/ip", limit: 300, period: 5.minutes) do |req|
    req.ip
  end
end

Limit the amount of connections to a specific resource

HTTP = ConnectionPool.new(size: 5, timeout: 5) { Net::HTTP }
HTTP.with do |conn|
  conn.get("/my-resource")
end

Returns:

  • (Integer)


358
# File 'lib/rage/configuration.rb', line 358

attr_accessor :port, :workers_count, :timeout, :max_clients

#portInteger

Specify the port the server will listen on.

Examples:

Change the default port

Rage.configure do
  config.server.port = 3001
end

Returns:

  • (Integer)


358
359
360
# File 'lib/rage/configuration.rb', line 358

def port
  @port
end

#timeoutInteger

Specify the connection timeout in seconds.

Examples:

Change the connection timeout

Rage.configure do
  config.server.timeout = 30
end

Returns:

  • (Integer)


358
# File 'lib/rage/configuration.rb', line 358

attr_accessor :port, :workers_count, :timeout, :max_clients

#workers_countInteger

Specify the number of worker processes to spawn. Use -1 to spawn one worker per CPU core.

Examples:

Change the number of worker processes

Rage.configure do
  config.server.workers_count = 4
end

Returns:

  • (Integer)


358
# File 'lib/rage/configuration.rb', line 358

attr_accessor :port, :workers_count, :timeout, :max_clients