Sha256: 031139dc3251295c0519871c167c2836b5ca0b6bbec60c6ab7b7b3cdea15b029
Contents?: true
Size: 1.74 KB
Versions: 7
Compression:
Stored size: 1.74 KB
Contents
# Copyright (C) 2013, Eric Wong <normalperson@yhbt.net> and all contributors # License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt) require 'yahns' module Yahns::RackupHandler # :nodoc: def self.default_host environment = ENV['RACK_ENV'] || 'development' environment == 'development' ? '127.0.0.1' : '0.0.0.0' end 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 =~ /,/ 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| x = x.to_sym val = o[x] and __send__(x, val) end end Yahns::Server.new(cfg).start.join end def self.valid_options # 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 end
Version data entries
7 entries across 7 versions & 1 rubygems