diff --git a/README.de.rdoc b/README.de.rdoc index 92f1df12..d33f088b 100644 --- a/README.de.rdoc +++ b/README.de.rdoc @@ -1520,6 +1520,7 @@ ohne dass sie einer Konstanten zugeordnet werden. Dies lässt sich mit Die Applikation kann mit Hilfe eines optionalen Parameters erstellt werden: + # config.ru require 'sinatra/base' controller = Sinatra.new do diff --git a/README.es.rdoc b/README.es.rdoc index 91a56906..0825d948 100644 --- a/README.es.rdoc +++ b/README.es.rdoc @@ -1581,6 +1581,7 @@ esto tenés Sinatra.new: Acepta como argumento opcional una aplicación desde la que se heredará: + # config.ru require 'sinatra/base' controller = Sinatra.new do diff --git a/README.fr.rdoc b/README.fr.rdoc index f6f0331f..ce430d36 100644 --- a/README.fr.rdoc +++ b/README.fr.rdoc @@ -1585,6 +1585,7 @@ sans avoir à les assigner à une constante, vous pouvez le faire grâce à L'application dont elle hérite peut être passé en argument optionnel : + # config.ru require 'sinatra/base' controleur = Sinatra.new do diff --git a/README.ru.rdoc b/README.ru.rdoc index 9a165a41..fd2d2f0b 100644 --- a/README.ru.rdoc +++ b/README.ru.rdoc @@ -1519,6 +1519,7 @@ Rack-совместимый сервер приложений. Этот метод может принимать аргументом приложение, от которого следует наследоваться: + # config.ru require 'sinatra/base' controller = Sinatra.new do diff --git a/lib/sinatra/base.rb b/lib/sinatra/base.rb index 48c0556a..8ae64668 100644 --- a/lib/sinatra/base.rb +++ b/lib/sinatra/base.rb @@ -1188,16 +1188,20 @@ module Sinatra end # Run the Sinatra app as a self-hosted server using - # Thin, Mongrel or WEBrick (in that order) + # Thin, Mongrel or WEBrick (in that order). If given a block, will call + # with the constructed handler once we have taken the stage. def run!(options={}) set options handler = detect_rack_handler handler_name = handler.name.gsub(/.*::/, '') - $stderr.puts "== Sinatra/#{Sinatra::VERSION} has taken the stage " + - "on #{port} for #{environment} with backup from #{handler_name}" unless handler_name =~/cgi/i handler.run self, :Host => bind, :Port => port do |server| + unless handler_name =~ /cgi/i + $stderr.puts "== Sinatra/#{Sinatra::VERSION} has taken the stage " + + "on #{port} for #{environment} with backup from #{handler_name}" + end [:INT, :TERM].each { |sig| trap(sig) { quit!(server, handler_name) } } set :running, true + yield handler if block_given? end rescue Errno::EADDRINUSE => e $stderr.puts "== Someone is already performing on port #{port}!"