1
0
Fork 0
mirror of https://github.com/puma/puma.git synced 2022-11-09 13:48:40 -05:00

Add output when used via rackup

This commit is contained in:
Evan Phoenix 2011-11-22 15:06:51 -08:00
parent d63967b7c6
commit 80eb913b1b

View file

@ -4,13 +4,27 @@ require 'puma'
module Rack module Rack
module Handler module Handler
module Puma module Puma
DEFAULT_OPTIONS = {:Host => '0.0.0.0', :Port => 8080, :Threads => '0:16'} DEFAULT_OPTIONS = {
:Host => '0.0.0.0',
:Port => 8080,
:Threads => '0:16',
:Quiet => false
}
def self.run(app, options = {}) def self.run(app, options = {})
options = DEFAULT_OPTIONS.merge(options) options = DEFAULT_OPTIONS.merge(options)
unless options[:Quiet]
app = Rack::CommonLogger.new(app, STDOUT)
end
server = ::Puma::Server.new(app) server = ::Puma::Server.new(app)
min, max = options[:Threads].split(':', 2) min, max = options[:Threads].split(':', 2)
puts "Puma #{::Puma::Const::PUMA_VERSION} starting..."
puts "* Min threads: #{min}, max threads: #{max}"
puts "* Listening on tcp://#{options[:Host]}:#{options[:Port]}"
server.add_tcp_listener options[:Host], options[:Port] server.add_tcp_listener options[:Host], options[:Port]
server.min_threads = Integer(min) server.min_threads = Integer(min)
server.max_threads = Integer(max) server.max_threads = Integer(max)
@ -23,7 +37,8 @@ module Rack
{ {
"Host=HOST" => "Hostname to listen on (default: localhost)", "Host=HOST" => "Hostname to listen on (default: localhost)",
"Port=PORT" => "Port to listen on (default: 8080)", "Port=PORT" => "Port to listen on (default: 8080)",
"Threads=MIN:MAX" => "min:max threads to use (default 0:16)" "Threads=MIN:MAX" => "min:max threads to use (default 0:16)",
"Quiet" => "Don't report each request"
} }
end end
end end