Module: Rackup::Handler::Raptor

Defined in:
lib/rackup/handler/raptor.rb,
sig/generated/rackup/handler/raptor.rbs

Overview

Rack handler for booting Raptor through Rackup, rails server, or any other host that follows the Rack handler protocol.

Constant Summary collapse

DEFAULT_OPTIONS =

Returns:

  • (Object)
{
  Host: "0.0.0.0",
  Port: 9292
}.freeze

Class Method Summary collapse

Class Method Details

.run(app, **options) {|cluster| ... } ⇒ void

This method returns an undefined value.

Boots a Raptor cluster serving the given Rack application.

Parameters:

  • app (#call)

    the Rack application to serve

  • options (Hash)

    handler options provided by Rackup or the host

Yields:

  • (cluster)

    the cluster instance, before it starts running

Yield Parameters:

Yield Returns:

  • (void)


25
26
27
28
29
30
31
32
33
34
# File 'lib/rackup/handler/raptor.rb', line 25

def self.run(app, **options)
  require_relative "../../raptor/cli"
  require_relative "../../raptor/cluster"

  cluster = ::Raptor::Cluster.new(build_cluster_options(app, options))

  yield cluster if block_given?

  cluster.run
end

.valid_optionsHash{String => String}

Returns the handler-specific options surfaced by rackup --help.

Returns:

  • (Hash{String => String})

    option spec to description mapping



41
42
43
44
45
46
47
48
49
# File 'lib/rackup/handler/raptor.rb', line 41

def self.valid_options
  {
    "Host=HOST"   => "Hostname to listen on (default: #{DEFAULT_OPTIONS[:Host]})",
    "Port=PORT"   => "Port to listen on (default: #{DEFAULT_OPTIONS[:Port]})",
    "Threads=NUM" => "Number of threads per worker (default: 3)",
    "Ractors=NUM" => "Number of pipeline ractors per worker (default: 1)",
    "Workers=NUM" => "Number of worker processes (default: nprocessors)"
  }
end