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
82
83
# File 'lib/falcon/command/virtual.rb', line 73

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
	
	ENV['CONSOLE_LEVEL'] = 'debug'
	
	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.



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

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.



86
87
88
# File 'lib/falcon/command/virtual.rb', line 86

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.



91
92
93
# File 'lib/falcon/command/virtual.rb', line 91

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