Module: Rackup::Handler::Kino
- Defined in:
- lib/rackup/handler/kino.rb
Overview
The Rack handler: lets any host that speaks the rackup protocol boot
Kino, which is what rackup -s kino and rails server -u kino do.
Loaded on demand by Rackup::Handler.get(:kino), so Rackup itself is
already defined here; Kino is required only when the host calls in.
Class Method Summary collapse
-
.run(app, **options) {|server| ... } ⇒ ::Kino::Server
Boot a server for
appand block until it shuts down, the way thekinoexecutable does (banner, INT/TERM drain, stats on USR1). -
.server_options(options) ⇒ Hash{Symbol => Object}
Translate host options into Kino::Server#initialize kwargs.
-
.valid_options ⇒ Hash{String => String}
The
-O NAME=VALUEoptionsrackup -s kino --helplists (rackup shows its own -o/-p in place of Host and Port).
Class Method Details
.run(app, **options) {|server| ... } ⇒ ::Kino::Server
Boot a server for app and block until it shuts down, the way the
kino executable does (banner, INT/TERM drain, stats on USR1).
29 30 31 32 33 34 |
# File 'lib/rackup/handler/kino.rb', line 29 def self.run(app, **) require "kino" # audition:disable runtime-require server = ::Kino::Server.new(app, **()) yield server if block_given? server.run end |
.server_options(options) ⇒ Hash{Symbol => Object}
Translate host options into Kino::Server#initialize kwargs.
Precedence: options the user typed > the config file > defaults the
host supplied (rackup's and Rails' own Host and Port) > Kino's
defaults. Hosts that say which options were typed pass
user_supplied_options; when that list is absent every option
counts as typed. Keys outside OPTION_MAP (the host's bookkeeping:
environment, pid, config, ...) are ignored.
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/rackup/handler/kino.rb', line 60 def self.() require "kino" # audition:disable runtime-require = .dup host_defaults = {} if (typed = .delete(:user_supplied_options)) (.keys - typed).each { |key| host_defaults[key] = .delete(key) } end config = ::Kino::Configuration.new path = .delete(:Config) || host_defaults.delete(:Config) || ::Kino::Configuration.default_path config.load_file(path) if path translate(host_defaults).each { |key, value| config.set(key, value) unless config.set?(key) } config.merge!(translate()) config.set(:port, ::Kino::Configuration::DEFAULT_SERVING_PORT) unless config.set?(:port) config. end |
.valid_options ⇒ Hash{String => String}
The -O NAME=VALUE options rackup -s kino --help lists (rackup
shows its own -o/-p in place of Host and Port).
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/rackup/handler/kino.rb', line 39 def self. { "Host=HOST" => "Address to bind (default: 127.0.0.1)", "Port=PORT" => "Port to listen on (default: 9292)", "Workers=COUNT" => "Workers: ractors in :ractor mode, thread groups in :threaded (default: one per CPU)", "Threads=COUNT" => "Threads per worker (default: 1 in :ractor, 3 in :threaded)", "Mode=MODE" => "auto | ractor | threaded (default: auto)", "Config=PATH" => "Kino config file (default: kino.rb, then config/kino.rb)" } end |