Class: Falcon::Command::Serve
- Inherits:
-
Samovar::Command
- Object
- Samovar::Command
- Falcon::Command::Serve
- Defined in:
- lib/falcon/command/serve.rb
Instance Method Summary collapse
- #cache? ⇒ Boolean
- #call ⇒ Object
- #client ⇒ Object
- #client_endpoint ⇒ Object
- #container_class ⇒ Object
- #container_options ⇒ Object
- #controller ⇒ Object
- #endpoint ⇒ Object
- #endpoint_options ⇒ Object
- #load_app ⇒ Object
- #slice_options(*keys) ⇒ Object
- #verbose? ⇒ Boolean
Instance Method Details
#cache? ⇒ Boolean
81 82 83 |
# File 'lib/falcon/command/serve.rb', line 81 def cache? [:cache] end |
#call ⇒ Object
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/falcon/command/serve.rb', line 128 def call Async.logger.info(self) do |buffer| buffer.puts "Falcon v#{VERSION} taking flight! Using #{self.container_class} #{self.container_options}." buffer.puts "- Binding to: #{self.endpoint}" buffer.puts "- To terminate: Ctrl-C or kill #{Process.pid}" buffer.puts "- To reload configuration: kill -HUP #{Process.pid}" end if path = [:preload] full_path = File.(path) load(full_path) end Bundler.require(:preload) if GC.respond_to?(:compact) GC.compact end self.controller.run end |
#client ⇒ Object
120 121 122 |
# File 'lib/falcon/command/serve.rb', line 120 def client Async::HTTP::Client.new(client_endpoint) end |
#client_endpoint ⇒ Object
116 117 118 |
# File 'lib/falcon/command/serve.rb', line 116 def client_endpoint Async::HTTP::Endpoint.parse([:bind], **) end |
#container_class ⇒ Object
66 67 68 69 70 71 72 73 74 75 |
# File 'lib/falcon/command/serve.rb', line 66 def container_class case [:container] when :threaded return Async::Container::Threaded when :forked return Async::Container::Forked when :hybrid return Async::Container::Hybrid end end |
#container_options ⇒ Object
104 105 106 |
# File 'lib/falcon/command/serve.rb', line 104 def (:count, :forks, :threads) end |
#controller ⇒ Object
124 125 126 |
# File 'lib/falcon/command/serve.rb', line 124 def controller Controller::Serve.new(self) end |
#endpoint ⇒ Object
112 113 114 |
# File 'lib/falcon/command/serve.rb', line 112 def endpoint Endpoint.parse([:bind], **) end |
#endpoint_options ⇒ Object
108 109 110 |
# File 'lib/falcon/command/serve.rb', line 108 def (:hostname, :port, :reuse_port, :timeout) end |
#load_app ⇒ Object
85 86 87 88 89 |
# File 'lib/falcon/command/serve.rb', line 85 def load_app rack_app, _ = Rack::Builder.parse_file([:config]) return Server.middleware(rack_app, verbose: self.verbose?, cache: self.cache?) end |
#slice_options(*keys) ⇒ Object
91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/falcon/command/serve.rb', line 91 def (*keys) # TODO: Ruby 2.5 introduced Hash#slice = {} keys.each do |key| if .key?(key) [key] = [key] end end return end |
#verbose? ⇒ Boolean
77 78 79 |
# File 'lib/falcon/command/serve.rb', line 77 def verbose? @parent&.verbose? end |