ok
Direktori : /opt/cpanel/ea-ruby27/root/usr/share/gems/doc/rack-2.2.8/rdoc/Rack/Server/ |
Current File : //opt/cpanel/ea-ruby27/root/usr/share/gems/doc/rack-2.2.8/rdoc/Rack/Server/Options.html |
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>class Rack::Server::Options - rack-2.2.8 Documentation</title> <script type="text/javascript"> var rdoc_rel_prefix = "../../"; var index_rel_prefix = "../../"; </script> <script src="../../js/navigation.js" defer></script> <script src="../../js/search.js" defer></script> <script src="../../js/search_index.js" defer></script> <script src="../../js/searcher.js" defer></script> <script src="../../js/darkfish.js" defer></script> <link href="../../css/fonts.css" rel="stylesheet"> <link href="../../css/rdoc.css" rel="stylesheet"> <body id="top" role="document" class="class"> <nav role="navigation"> <div id="project-navigation"> <div id="home-section" role="region" title="Quick navigation" class="nav-section"> <h2> <a href="../../index.html" rel="home">Home</a> </h2> <div id="table-of-contents-navigation"> <a href="../../table_of_contents.html#pages">Pages</a> <a href="../../table_of_contents.html#classes">Classes</a> <a href="../../table_of_contents.html#methods">Methods</a> </div> </div> <div id="search-section" role="search" class="project-section initially-hidden"> <form action="#" method="get" accept-charset="utf-8"> <div id="search-field-wrapper"> <input id="search-field" role="combobox" aria-label="Search" aria-autocomplete="list" aria-controls="search-results" type="text" name="search" placeholder="Search" spellcheck="false" title="Type to search, Up and Down to navigate, Enter to load"> </div> <ul id="search-results" aria-label="Search Results" aria-busy="false" aria-expanded="false" aria-atomic="false" class="initially-hidden"></ul> </form> </div> </div> <div id="class-metadata"> <div id="parent-class-section" class="nav-section"> <h3>Parent</h3> <p class="link">Object </div> <!-- Method Quickref --> <div id="method-list-section" class="nav-section"> <h3>Methods</h3> <ul class="link-list" role="directory"> <li ><a href="#method-i-handler_opts">#handler_opts</a> <li ><a href="#method-i-parse-21">#parse!</a> </ul> </div> </div> </nav> <main role="main" aria-labelledby="class-Rack::Server::Options"> <h1 id="class-Rack::Server::Options" class="class"> class Rack::Server::Options </h1> <section class="description"> </section> <section id="5Buntitled-5D" class="documentation-section"> <section id="public-instance-5Buntitled-5D-method-details" class="method-section"> <header> <h3>Public Instance Methods</h3> </header> <div id="method-i-handler_opts" class="method-detail "> <div class="method-heading"> <span class="method-name">handler_opts</span><span class="method-args">(options)</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <div class="method-source-code" id="handler_opts-source"> <pre><span class="ruby-comment"># File lib/rack/server.rb, line 127</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">handler_opts</span>(<span class="ruby-identifier">options</span>) <span class="ruby-keyword">begin</span> <span class="ruby-identifier">info</span> = [] <span class="ruby-identifier">server</span> = <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Handler</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">options</span>[<span class="ruby-value">:server</span>]) <span class="ruby-operator">||</span> <span class="ruby-constant">Rack</span><span class="ruby-operator">::</span><span class="ruby-constant">Handler</span>.<span class="ruby-identifier">default</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">server</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">server</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-value">:valid_options</span>) <span class="ruby-identifier">info</span> <span class="ruby-operator"><<</span> <span class="ruby-string">""</span> <span class="ruby-identifier">info</span> <span class="ruby-operator"><<</span> <span class="ruby-node">"Server-specific options for #{server.name}:"</span> <span class="ruby-identifier">has_options</span> = <span class="ruby-keyword">false</span> <span class="ruby-identifier">server</span>.<span class="ruby-identifier">valid_options</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">name</span>, <span class="ruby-identifier">description</span><span class="ruby-operator">|</span> <span class="ruby-keyword">next</span> <span class="ruby-keyword">if</span> <span class="ruby-regexp">/^(Host|Port)[^a-zA-Z]/</span>.<span class="ruby-identifier">match?</span>(<span class="ruby-identifier">name</span>.<span class="ruby-identifier">to_s</span>) <span class="ruby-comment"># ignore handler's host and port options, we do our own.</span> <span class="ruby-identifier">info</span> <span class="ruby-operator"><<</span> <span class="ruby-string">" -O %-21s %s"</span> <span class="ruby-operator">%</span> [<span class="ruby-identifier">name</span>, <span class="ruby-identifier">description</span>] <span class="ruby-identifier">has_options</span> = <span class="ruby-keyword">true</span> <span class="ruby-keyword">end</span> <span class="ruby-keyword">return</span> <span class="ruby-string">""</span> <span class="ruby-keyword">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">has_options</span> <span class="ruby-keyword">end</span> <span class="ruby-identifier">info</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">"\n"</span>) <span class="ruby-keyword">rescue</span> <span class="ruby-constant">NameError</span>, <span class="ruby-constant">LoadError</span> <span class="ruby-keyword">return</span> <span class="ruby-node">"Warning: Could not find handler specified (#{options[:server] || 'default'}) to determine handler-specific options"</span> <span class="ruby-keyword">end</span> <span class="ruby-keyword">end</span></pre> </div> </div> </div> <div id="method-i-parse-21" class="method-detail "> <div class="method-heading"> <span class="method-name">parse!</span><span class="method-args">(args)</span> <span class="method-click-advice">click to toggle source</span> </div> <div class="method-description"> <div class="method-source-code" id="parse-21-source"> <pre><span class="ruby-comment"># File lib/rack/server.rb, line 12</span> <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">parse!</span>(<span class="ruby-identifier">args</span>) <span class="ruby-identifier">options</span> = {} <span class="ruby-identifier">opt_parser</span> = <span class="ruby-constant">OptionParser</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">""</span>, <span class="ruby-value">24</span>, <span class="ruby-string">' '</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">opts</span><span class="ruby-operator">|</span> <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">banner</span> = <span class="ruby-string">"Usage: rackup [ruby options] [rack options] [rackup config]"</span> <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">separator</span> <span class="ruby-string">""</span> <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">separator</span> <span class="ruby-string">"Ruby options:"</span> <span class="ruby-identifier">lineno</span> = <span class="ruby-value">1</span> <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">"-e"</span>, <span class="ruby-string">"--eval LINE"</span>, <span class="ruby-string">"evaluate a LINE of code"</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">line</span><span class="ruby-operator">|</span> <span class="ruby-identifier">eval</span> <span class="ruby-identifier">line</span>, <span class="ruby-constant">TOPLEVEL_BINDING</span>, <span class="ruby-string">"-e"</span>, <span class="ruby-identifier">lineno</span> <span class="ruby-identifier">lineno</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span> } <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">"-d"</span>, <span class="ruby-string">"--debug"</span>, <span class="ruby-string">"set debugging flags (set $DEBUG to true)"</span>) { <span class="ruby-identifier">options</span>[<span class="ruby-value">:debug</span>] = <span class="ruby-keyword">true</span> } <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">"-w"</span>, <span class="ruby-string">"--warn"</span>, <span class="ruby-string">"turn warnings on for your script"</span>) { <span class="ruby-identifier">options</span>[<span class="ruby-value">:warn</span>] = <span class="ruby-keyword">true</span> } <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">"-q"</span>, <span class="ruby-string">"--quiet"</span>, <span class="ruby-string">"turn off logging"</span>) { <span class="ruby-identifier">options</span>[<span class="ruby-value">:quiet</span>] = <span class="ruby-keyword">true</span> } <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">"-I"</span>, <span class="ruby-string">"--include PATH"</span>, <span class="ruby-string">"specify $LOAD_PATH (may be used more than once)"</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">path</span><span class="ruby-operator">|</span> (<span class="ruby-identifier">options</span>[<span class="ruby-value">:include</span>] <span class="ruby-operator">||=</span> []).<span class="ruby-identifier">concat</span>(<span class="ruby-identifier">path</span>.<span class="ruby-identifier">split</span>(<span class="ruby-string">":"</span>)) } <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">"-r"</span>, <span class="ruby-string">"--require LIBRARY"</span>, <span class="ruby-string">"require the library, before executing your script"</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">library</span><span class="ruby-operator">|</span> (<span class="ruby-identifier">options</span>[<span class="ruby-value">:require</span>] <span class="ruby-operator">||=</span> []) <span class="ruby-operator"><<</span> <span class="ruby-identifier">library</span> } <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">separator</span> <span class="ruby-string">""</span> <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">separator</span> <span class="ruby-string">"Rack options:"</span> <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">"-b"</span>, <span class="ruby-string">"--builder BUILDER_LINE"</span>, <span class="ruby-string">"evaluate a BUILDER_LINE of code as a builder script"</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">line</span><span class="ruby-operator">|</span> <span class="ruby-identifier">options</span>[<span class="ruby-value">:builder</span>] = <span class="ruby-identifier">line</span> } <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">"-s"</span>, <span class="ruby-string">"--server SERVER"</span>, <span class="ruby-string">"serve using SERVER (thin/puma/webrick)"</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">s</span><span class="ruby-operator">|</span> <span class="ruby-identifier">options</span>[<span class="ruby-value">:server</span>] = <span class="ruby-identifier">s</span> } <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">"-o"</span>, <span class="ruby-string">"--host HOST"</span>, <span class="ruby-string">"listen on HOST (default: localhost)"</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">host</span><span class="ruby-operator">|</span> <span class="ruby-identifier">options</span>[<span class="ruby-value">:Host</span>] = <span class="ruby-identifier">host</span> } <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">"-p"</span>, <span class="ruby-string">"--port PORT"</span>, <span class="ruby-string">"use PORT (default: 9292)"</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">port</span><span class="ruby-operator">|</span> <span class="ruby-identifier">options</span>[<span class="ruby-value">:Port</span>] = <span class="ruby-identifier">port</span> } <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">"-O"</span>, <span class="ruby-string">"--option NAME[=VALUE]"</span>, <span class="ruby-node">"pass VALUE to the server as option NAME. If no VALUE, sets it to true. Run '#{$0} -s SERVER -h' to get a list of options for SERVER"</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">name</span><span class="ruby-operator">|</span> <span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span> = <span class="ruby-identifier">name</span>.<span class="ruby-identifier">split</span>(<span class="ruby-string">'='</span>, <span class="ruby-value">2</span>) <span class="ruby-identifier">value</span> = <span class="ruby-keyword">true</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">name</span>.<span class="ruby-identifier">to_sym</span>] = <span class="ruby-identifier">value</span> } <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">"-E"</span>, <span class="ruby-string">"--env ENVIRONMENT"</span>, <span class="ruby-string">"use ENVIRONMENT for defaults (default: development)"</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">e</span><span class="ruby-operator">|</span> <span class="ruby-identifier">options</span>[<span class="ruby-value">:environment</span>] = <span class="ruby-identifier">e</span> } <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">"-D"</span>, <span class="ruby-string">"--daemonize"</span>, <span class="ruby-string">"run daemonized in the background"</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">d</span><span class="ruby-operator">|</span> <span class="ruby-identifier">options</span>[<span class="ruby-value">:daemonize</span>] = <span class="ruby-identifier">d</span> <span class="ruby-operator">?</span> <span class="ruby-keyword">true</span> <span class="ruby-operator">:</span> <span class="ruby-keyword">false</span> } <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">"-P"</span>, <span class="ruby-string">"--pid FILE"</span>, <span class="ruby-string">"file to store PID"</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span> <span class="ruby-identifier">options</span>[<span class="ruby-value">:pid</span>] = <span class="ruby-operator">::</span><span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>(<span class="ruby-identifier">f</span>) } <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">separator</span> <span class="ruby-string">""</span> <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">separator</span> <span class="ruby-string">"Profiling options:"</span> <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">"--heap HEAPFILE"</span>, <span class="ruby-string">"Build the application, then dump the heap to HEAPFILE"</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">e</span><span class="ruby-operator">|</span> <span class="ruby-identifier">options</span>[<span class="ruby-value">:heapfile</span>] = <span class="ruby-identifier">e</span> <span class="ruby-keyword">end</span> <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">"--profile PROFILE"</span>, <span class="ruby-string">"Dump CPU or Memory profile to PROFILE (defaults to a tempfile)"</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">e</span><span class="ruby-operator">|</span> <span class="ruby-identifier">options</span>[<span class="ruby-value">:profile_file</span>] = <span class="ruby-identifier">e</span> <span class="ruby-keyword">end</span> <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on</span>(<span class="ruby-string">"--profile-mode MODE"</span>, <span class="ruby-string">"Profile mode (cpu|wall|object)"</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">e</span><span class="ruby-operator">|</span> { <span class="ruby-value">cpu:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">wall:</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">object:</span> <span class="ruby-keyword">true</span> }.<span class="ruby-identifier">fetch</span>(<span class="ruby-identifier">e</span>.<span class="ruby-identifier">to_sym</span>) <span class="ruby-keyword">do</span> <span class="ruby-identifier">raise</span> <span class="ruby-constant">OptionParser</span><span class="ruby-operator">::</span><span class="ruby-constant">InvalidOption</span>, <span class="ruby-node">"unknown profile mode: #{e}"</span> <span class="ruby-keyword">end</span> <span class="ruby-identifier">options</span>[<span class="ruby-value">:profile_mode</span>] = <span class="ruby-identifier">e</span>.<span class="ruby-identifier">to_sym</span> <span class="ruby-keyword">end</span> <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">separator</span> <span class="ruby-string">""</span> <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">separator</span> <span class="ruby-string">"Common options:"</span> <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on_tail</span>(<span class="ruby-string">"-h"</span>, <span class="ruby-string">"-?"</span>, <span class="ruby-string">"--help"</span>, <span class="ruby-string">"Show this message"</span>) <span class="ruby-keyword">do</span> <span class="ruby-identifier">puts</span> <span class="ruby-identifier">opts</span> <span class="ruby-identifier">puts</span> <span class="ruby-identifier">handler_opts</span>(<span class="ruby-identifier">options</span>) <span class="ruby-identifier">exit</span> <span class="ruby-keyword">end</span> <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">on_tail</span>(<span class="ruby-string">"--version"</span>, <span class="ruby-string">"Show version"</span>) <span class="ruby-keyword">do</span> <span class="ruby-identifier">puts</span> <span class="ruby-node">"Rack #{Rack.version} (Release: #{Rack.release})"</span> <span class="ruby-identifier">exit</span> <span class="ruby-keyword">end</span> <span class="ruby-keyword">end</span> <span class="ruby-keyword">begin</span> <span class="ruby-identifier">opt_parser</span>.<span class="ruby-identifier">parse!</span> <span class="ruby-identifier">args</span> <span class="ruby-keyword">rescue</span> <span class="ruby-constant">OptionParser</span><span class="ruby-operator">::</span><span class="ruby-constant">InvalidOption</span> <span class="ruby-operator">=></span> <span class="ruby-identifier">e</span> <span class="ruby-identifier">warn</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">message</span> <span class="ruby-identifier">abort</span> <span class="ruby-identifier">opt_parser</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-keyword">end</span> <span class="ruby-identifier">options</span>[<span class="ruby-value">:config</span>] = <span class="ruby-identifier">args</span>.<span class="ruby-identifier">last</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">args</span>.<span class="ruby-identifier">last</span> <span class="ruby-operator">&&</span> <span class="ruby-operator">!</span><span class="ruby-identifier">args</span>.<span class="ruby-identifier">last</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-identifier">options</span> <span class="ruby-keyword">end</span></pre> </div> </div> </div> </section> </section> </main> <footer id="validator-badges" role="contentinfo"> <p><a href="https://validator.w3.org/check/referer">Validate</a> <p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.2.1.1. <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>. </footer>