class Falcon::Command::Serve
Manages a {Controller::Serve} instance which is responsible for running applications in a development environment.
Implements the ‘falcon serve` command. Designed for development.
def cache?
Whether to enable the application HTTP cache.
def cache? @options[:cache] end
def call
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 = @options[:preload] full_path = File.expand_path(path) load(full_path) end begin Bundler.require(:preload) rescue Bundler::GemfileNotFound # Ignore. end if GC.respond_to?(:compact) GC.compact end self.controller.run end
def client
def client Async::HTTP::Client.new(client_endpoint) end
def client_endpoint
def client_endpoint Async::HTTP::Endpoint.parse(@options[:bind], **endpoint_options) end
def container_class
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
def container_options
Options for the container.
def container_options @options.slice(:count, :forks, :threads) end
def controller
def controller Controller::Serve.new(self) end
def endpoint
def endpoint Endpoint.parse(@options[:bind], **endpoint_options) end
def endpoint_options
def endpoint_options @options.slice(:hostname, :port, :reuse_port, :timeout) end
def load_app
Load the rack application from the specified configuration path.
def load_app rack_app, _ = Rack::Builder.parse_file(@options[:config]) return Server.middleware(rack_app, verbose: self.verbose?, cache: self.cache?) end
def verbose?
Whether verbose logging is enabled.
def verbose? @parent&.verbose? end