Class: Falcon::Command::Virtual
- Inherits:
-
Samovar::Command
- Object
- Samovar::Command
- Falcon::Command::Virtual
- Defined in:
- lib/falcon/command/virtual.rb
Overview
Instance Attribute Summary collapse
-
#paths ⇒ Object
readonly
One or more paths to the configuration files.
Instance Method Summary collapse
-
#call ⇒ Object
Prepare the environment and run the controller.
-
#configuration ⇒ Object
Build the service configuration for the virtual host.
-
#environment ⇒ Object
Create the environment for the virtual host service.
-
#host_endpoint(hostname, path: "/", **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.
Instance Attribute Details
#paths ⇒ Object (readonly)
One or more paths to the configuration files.
32 |
# File 'lib/falcon/command/virtual.rb', line 32 many :paths |
Instance Method Details
#call ⇒ Object
Prepare the environment and run the controller.
55 56 57 58 59 60 61 62 63 64 |
# File 'lib/falcon/command/virtual.rb', line 55 def call Console.info(self) do |buffer| buffer.puts "Falcon Virtual v#{VERSION} taking flight!" buffer.puts "- Running on #{RUBY_DESCRIPTION}" 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 |
#configuration ⇒ Object
Build the service configuration for the virtual host.
48 49 50 51 52 |
# File 'lib/falcon/command/virtual.rb', line 48 def configuration Async::Service::Configuration.new.tap do |configuration| configuration.add(self.environment) end end |
#environment ⇒ Object
Create the environment for the virtual host service.
36 37 38 39 40 41 42 43 44 |
# File 'lib/falcon/command/virtual.rb', line 36 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 |
#host_endpoint(hostname, path: "/", **options) ⇒ Object
An endpoint suitable for connecting to the specified hostname.
77 78 79 80 81 82 83 84 85 |
# File 'lib/falcon/command/virtual.rb', line 77 def host_endpoint(hostname, path: "/", **) endpoint = secure_endpoint(**) url = URI.parse(@options[:bind_secure]) url.hostname = hostname url.path = path return Async::HTTP::Endpoint.new(url, hostname: endpoint.hostname) end |
#insecure_endpoint(**options) ⇒ Object
The insecure endpoint for connecting to the Redirect instance.
67 68 69 |
# File 'lib/falcon/command/virtual.rb', line 67 def insecure_endpoint(**) Async::HTTP::Endpoint.parse(@options[:bind_insecure], **) end |
#secure_endpoint(**options) ⇒ Object
The secure endpoint for connecting to the Proxy instance.
72 73 74 |
# File 'lib/falcon/command/virtual.rb', line 72 def secure_endpoint(**) Async::HTTP::Endpoint.parse(@options[:bind_secure], **) end |