Module: Yahns::RackupHandler
- Defined in:
- lib/yahns/rackup_handler.rb
Overview
:nodoc:
Class Method Summary collapse
- .default_host ⇒ Object
- .run(app, o) ⇒ Object
-
.valid_options ⇒ Object
this is called by Rack::Server.
Class Method Details
.default_host ⇒ Object
7 8 9 10 |
# File 'lib/yahns/rackup_handler.rb', line 7 def self.default_host environment = ENV['RACK_ENV'] || 'development' environment == 'development' ? '127.0.0.1' : '0.0.0.0' end |
.run(app, o) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/yahns/rackup_handler.rb', line 12 def self.run(app, o) cfg = Yahns::Config.new cfg.instance_eval do # we need this because "rackup -D" sends us to "/", which might be # fine for most apps, but we have SIGUSR2 restarts to support working_directory(Yahns::START[:cwd]) app(:rack, app) do addr = o[:listen] || "#{o[:Host]||default_host}:#{o[:Port]||8080}" # allow listening to multiple addresses if addr.include?(',') addr.split(',').each { |l| listen(l) } else listen addr end val = o[:client_timeout] and client_timeout(val) end queue do wt = o[:worker_threads] and worker_threads(wt) end %w(stderr_path stdout_path).each do |x| val = o[x] and __send__(x, val) end end Yahns::Server.new(cfg).start.join end |
.valid_options ⇒ Object
this is called by Rack::Server
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/yahns/rackup_handler.rb', line 43 def self. # these should be the most common options { "listen=ADDRESS" => "address(es) to listen on (e.g. /tmp/sock)", "worker_threads=NUM" => "number of worker threads to run", # this affects how quickly graceful shutdown goes "client_timeout=SECONDS" => "timeout for idle clients", # I don't want these here, but rackup supports daemonize and # we lose useful information when that sends stdout/stderr to /dev/null "stderr_path=PATH" => "stderr destination", "stdout_path=PATH" => "stdout destination", } end |