class Virtual
Implements the falcon virtual command. Designed for deployment.
Manages a Controller::Virtual instance which is responsible for running the class Falcon::Command::Proxy and class Falcon::Command::Redirect instances.
Nested
Definitions
many :paths
One or more paths to the configuration files.
Signature
-
attribute
Array(String)
def environment
Create the environment for the virtual host service.
Signature
-
returns
Async::Service::Environment The configured virtual environment.
Implementation
def environment
Async::Service::Environment.new(Falcon::Environment::Virtual).with(
verbose: self.parent&.verbose?,
configuration_paths: self.paths,
bind_insecure: @options[:bind_insecure],
bind_secure: @options[:bind_secure],
timeout: @options[:timeout],
)
end
def configuration
Build the service configuration for the virtual host.
Signature
-
returns
Async::Service::Configuration The service configuration.
Implementation
def configuration
Async::Service::Configuration.new.tap do |configuration|
configuration.add(self.environment)
end
end
def call
Prepare the environment and run the controller.
Implementation
def call
Console.logger.info(self) do |buffer|
buffer.puts "Falcon Virtual v#{VERSION} taking flight!"
buffer.puts "- Running on #{RUBY_DESCRIPTION}"
buffer.puts "- To terminate: Ctrl-C or kill #{Process.pid}"
buffer.puts "- To reload all sites: kill -HUP #{Process.pid}"
end
Async::Service::Controller.run(self.configuration)
end
def insecure_endpoint(**options)
The insecure endpoint for connecting to the class Falcon::Command::Redirect instance.
Implementation
def insecure_endpoint(**options)
Async::HTTP::Endpoint.parse(@options[:bind_insecure], **options)
end
def secure_endpoint(**options)
The secure endpoint for connecting to the class Falcon::Command::Proxy instance.
Implementation
def secure_endpoint(**options)
Async::HTTP::Endpoint.parse(@options[:bind_secure], **options)
end
def host_endpoint(hostname, path: "/", **options)
An endpoint suitable for connecting to the specified hostname.
Implementation
def host_endpoint(hostname, path: "/", **options)
endpoint = secure_endpoint(**options)
url = URI.parse(@options[:bind_secure])
url.hostname = hostname
url.path = path
return Async::HTTP::Endpoint.new(url, hostname: endpoint.hostname)
end