class Serve
Implements the falcon serve
command. Designed for development.
Manages a Controller::Serve
instance which is responsible for running applications in a development environment.
Nested
Definitions
def container_class
The container class to use.
Implementation
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 endpoint
The endpoint to bind to.
Implementation
def endpoint
Endpoint.parse(@options[:bind], **endpoint_options)
end
def client_endpoint
The endpoint suitable for a client to connect.
Implementation
def client_endpoint
Async::HTTP::Endpoint.parse(@options[:bind], **endpoint_options)
end
def client
Create a new client suitable for accessing the application.
Implementation
def client
Async::HTTP::Client.new(client_endpoint)
end
def call
Prepare the environment and run the controller.
Implementation
def call
Console.logger.info(self) do |buffer|
buffer.puts "Falcon v#{VERSION} taking flight! Using #{self.container_class} #{self.container_options}."
buffer.puts "- Running on #{RUBY_DESCRIPTION}"
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
Async::Service::Controller.run(self.configuration, container_class: self.container_class, graceful_stop: @options[:graceful_stop])
end