From 80eb913b1b62e0024389e7c37b9a0b57328d31e6 Mon Sep 17 00:00:00 2001 From: Evan Phoenix Date: Tue, 22 Nov 2011 15:06:51 -0800 Subject: [PATCH] Add output when used via rackup --- lib/rack/handler/puma.rb | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/rack/handler/puma.rb b/lib/rack/handler/puma.rb index 99fb7ee8..eeec3b52 100644 --- a/lib/rack/handler/puma.rb +++ b/lib/rack/handler/puma.rb @@ -4,13 +4,27 @@ require 'puma' module Rack module Handler 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 = {}) options = DEFAULT_OPTIONS.merge(options) + + unless options[:Quiet] + app = Rack::CommonLogger.new(app, STDOUT) + end + server = ::Puma::Server.new(app) 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.min_threads = Integer(min) server.max_threads = Integer(max) @@ -23,7 +37,8 @@ module Rack { "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)" + "Threads=MIN:MAX" => "min:max threads to use (default 0:16)", + "Quiet" => "Don't report each request" } end end