FalconSourceFalconCommandVirtual

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.

Definitions

options { ... }

The command line options.

Signature

attribute Samovar::Options

Implementation

options do
	option "--bind-insecure <address>", "Bind redirection to the given hostname/address", default: "http://[::]:80"
	option "--bind-secure <address>", "Bind proxy to the given hostname/address", default: "https://[::]:443"
	
	option "-t/--timeout <duration>", "Specify the maximum time to wait for non-blocking operations.", type: Float, default: 30
end

many :paths

One or more paths to the configuration files.

Signature

attribute Array(String)

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 "- 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