Class: Falcon::Command::Virtual
- Inherits:
-
Samovar::Command
- Object
- Samovar::Command
- Falcon::Command::Virtual
- 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
-
#paths ⇒ Object
readonly
One or more paths to the configuration files.
Instance Method Summary collapse
-
#bind_insecure ⇒ Object
The URI to bind the `HTTP` -> `HTTPS` redirector.
-
#bind_secure ⇒ Object
The URI to bind the `HTTPS` -> `falcon host` proxy.
-
#call ⇒ Object
Prepare the environment and run the controller.
-
#controller ⇒ Object
Prepare a new controller for the command.
-
#host_endpoint(hostname, **options) ⇒ Object
An endpoint suitable for connecting to the specified hostname.
-
#insecure_endpoint(**options) ⇒ Object
The insecure endpoint for connecting to the Redirect instance.
-
#secure_endpoint(**options) ⇒ Object
The secure endpoint for connecting to the Proxy instance.
-
#timeout ⇒ Object
The connection timeout to use for incoming connections.
Methods included from Paths
#configuration, #resolved_paths
Instance Attribute Details
#paths ⇒ Object (readonly)
One or more paths to the configuration files.
48 |
# File 'lib/falcon/command/virtual.rb', line 48 many :paths |
Instance Method Details
#bind_insecure ⇒ Object
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_secure ⇒ Object
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 |
#call ⇒ Object
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 |
#controller ⇒ Object
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, **) endpoint = secure_endpoint(**) 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(**) Async::HTTP::Endpoint.parse(@options[:bind_insecure], **) 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(**) Async::HTTP::Endpoint.parse(@options[:bind_secure], **) end |
#timeout ⇒ Object
The connection timeout to use for incoming connections.
68 69 70 |
# File 'lib/falcon/command/virtual.rb', line 68 def timeout @options[:timeout] end |