Class: Falcon::Command::Serve
- Inherits:
-
Samovar::Command
- Object
- Samovar::Command
- Falcon::Command::Serve
- Defined in:
- lib/falcon/command/serve.rb
Instance Method Summary collapse
- #call ⇒ Object
- #client ⇒ Object
- #client_endpoint ⇒ Object
- #container_class ⇒ Object
- #container_options ⇒ Object
- #controller ⇒ Object
- #endpoint ⇒ Object
- #endpoint_options ⇒ Object
- #load_app(verbose = self.verbose?) ⇒ Object
- #slice_options(*keys) ⇒ Object
- #verbose? ⇒ Boolean
Instance Method Details
#call ⇒ Object
122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/falcon/command/serve.rb', line 122 def call Async.logger.info(self.endpoint) do |buffer| buffer.puts "Falcon v#{VERSION} taking flight! Using #{self.container_class} #{self.}." buffer.puts "- To terminate: Ctrl-C or kill #{Process.pid}" buffer.puts "- To reload configuration: kill -HUP #{Process.pid}" end if @options[:preload] Bundler.require(:preload) end self.controller.run end |
#client ⇒ Object
114 115 116 |
# File 'lib/falcon/command/serve.rb', line 114 def client Async::HTTP::Client.new(client_endpoint) end |
#client_endpoint ⇒ Object
110 111 112 |
# File 'lib/falcon/command/serve.rb', line 110 def client_endpoint Async::HTTP::Endpoint.parse(@options[:bind], **) end |
#container_class ⇒ Object
64 65 66 67 68 69 70 71 72 73 |
# File 'lib/falcon/command/serve.rb', line 64 def container_class case @options[:container] when :threaded return Async::Container::Threaded when :forked return Async::Container::Forked when :hybrid return Async::Container::Hybrid end end |
#container_options ⇒ Object
98 99 100 |
# File 'lib/falcon/command/serve.rb', line 98 def (:count, :forks, :threads) end |
#controller ⇒ Object
118 119 120 |
# File 'lib/falcon/command/serve.rb', line 118 def controller Controller::Serve.new(self) end |
#endpoint ⇒ Object
106 107 108 |
# File 'lib/falcon/command/serve.rb', line 106 def endpoint Endpoint.parse(@options[:bind], **) end |
#endpoint_options ⇒ Object
102 103 104 |
# File 'lib/falcon/command/serve.rb', line 102 def (:hostname, :port, :reuse_port, :timeout) end |
#load_app(verbose = self.verbose?) ⇒ Object
79 80 81 82 83 |
# File 'lib/falcon/command/serve.rb', line 79 def load_app(verbose = self.verbose?) rack_app, = Rack::Builder.parse_file(@options[:config]) return Server.middleware(rack_app, verbose: verbose), end |
#slice_options(*keys) ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/falcon/command/serve.rb', line 85 def (*keys) # TODO: Ruby 2.5 introduced Hash#slice = {} keys.each do |key| if @options.key?(key) [key] = @options[key] end end return end |
#verbose? ⇒ Boolean
75 76 77 |
# File 'lib/falcon/command/serve.rb', line 75 def verbose? @parent&.verbose? end |