Sha256: 918fcc4c50d6637cb76dd0c2b5ffc69f292034145022e345979b5b46d6878908

Contents?: true

Size: 887 Bytes

Versions: 2

Compression:

Stored size: 887 Bytes

Contents

require 'rack/handler'
require 'puma'

module Rack
  module Handler
    module Puma
      DEFAULT_OPTIONS = {:Host => '0.0.0.0', :Port => 8080, :Threads => '0:16'}

      def self.run(app, options = {})
        options  = DEFAULT_OPTIONS.merge(options)
        server   = ::Puma::Server.new(app)
        min, max = options[:Threads].split(':', 2)

        server.add_tcp_listener options[:Host], options[:Port]
        server.min_threads = Integer(min)
        server.max_threads = Integer(max)
        yield server if block_given?

        server.run.join
      end

      def self.valid_options
        {
          "Host=HOST"       => "Hostname to listen on (default: localhost)",
          "Port=PORT"       => "Port to listen on (default: 8080)",
          "Threads=MIN:MAX" => "min:max threads to use (default 0:16)"
        }
      end
    end

    register :puma, Puma
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
puma-0.8.1 lib/rack/handler/puma.rb
puma-0.8.0 lib/rack/handler/puma.rb