class Falcon::Command::Virtual

Manages a {Controller::Virtual} instance which is responsible for running the {Proxy} and {Redirect} instances.
Implements the ‘falcon virtual` command. Designed for deployment.

def call

Prepare the environment and run the controller.
def call
	Console.logger.info(self) do |buffer|
		buffer.puts "Falcon Virtual v#{VERSION} taking flight!"
		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 configuration

def configuration
	Async::Service::Configuration.new.tap do |configuration|
		configuration.add(self.environment)
	end
end

def environment

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 host_endpoint(hostname, **options)

An endpoint suitable for connecting to the specified hostname.
def host_endpoint(hostname, **options)
	endpoint = secure_endpoint(**options)
	
	url = URI.parse(@options[:bind_secure])
	url.hostname = hostname
	
	return Async::HTTP::Endpoint.new(url, hostname: endpoint.hostname)
end

def insecure_endpoint(**options)

The insecure endpoint for connecting to the {Redirect} instance.
def insecure_endpoint(**options)
	Async::HTTP::Endpoint.parse(@options[:bind_insecure], **options)
end

def secure_endpoint(**options)

The secure endpoint for connecting to the {Proxy} instance.
def secure_endpoint(**options)
	Async::HTTP::Endpoint.parse(@options[:bind_secure], **options)
end