Class: Falcon::Command::Virtual

Inherits:
Samovar::Command
  • Object
show all
Includes:
Paths
Defined in:
lib/falcon/command/virtual.rb

Overview

Implements the ‘falcon virtual` command. Designed for deployment.

Manages a Falcon::Controller::Virtual instance which is responsible for running the Proxy and Redirect instances.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Paths

#configuration, #resolved_paths

Instance Attribute Details

#pathsObject (readonly)

One or more paths to the configuration files.



48
# File 'lib/falcon/command/virtual.rb', line 48

many :paths

Instance Method Details

#bind_insecureObject

The URI to bind the ‘HTTP` -> `HTTPS` redirector.



63
64
65
# File 'lib/falcon/command/virtual.rb', line 63

def bind_insecure
	@options[:bind_insecure]
end

#bind_secureObject

The URI to bind the ‘HTTPS` -> `falcon host` proxy.



58
59
60
# File 'lib/falcon/command/virtual.rb', line 58

def bind_secure
	@options[:bind_secure]
end

#callObject

Prepare the environment and run the controller.



73
74
75
76
77
78
79
80
81
# File 'lib/falcon/command/virtual.rb', line 73

def call
	Async.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
	
	self.controller.run
end

#controllerObject

Prepare a new controller for the command.



53
54
55
# File 'lib/falcon/command/virtual.rb', line 53

def controller
	Controller::Virtual.new(self)
end

#host_endpoint(hostname, **options) ⇒ Object

An endpoint suitable for connecting to the specified hostname.



94
95
96
97
98
99
100
101
# File 'lib/falcon/command/virtual.rb', line 94

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

#insecure_endpoint(**options) ⇒ Object

The insecure endpoint for connecting to the Redirect instance.



84
85
86
# File 'lib/falcon/command/virtual.rb', line 84

def insecure_endpoint(**options)
	Async::HTTP::Endpoint.parse(@options[:bind_insecure], **options)
end

#secure_endpoint(**options) ⇒ Object

The secure endpoint for connecting to the Proxy instance.



89
90
91
# File 'lib/falcon/command/virtual.rb', line 89

def secure_endpoint(**options)
	Async::HTTP::Endpoint.parse(@options[:bind_secure], **options)
end

#timeoutObject

The connection timeout to use for incoming connections.



68
69
70
# File 'lib/falcon/command/virtual.rb', line 68

def timeout
	@options[:timeout]
end