Class: Falcon::Command::Proxy

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

Overview

Implements the ‘falcon proxy` command.

Manages a Controller::Proxy instance which is responsible for proxing incoming requests.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Paths

#resolved_paths

Instance Attribute Details

#pathsObject (readonly)

One or more paths to the configuration files.



30
# File 'lib/falcon/command/proxy.rb', line 30

many :paths

Instance Method Details

#callObject

Prepare the environment and run the controller.



52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/falcon/command/proxy.rb', line 52

def call
	Console.logger.info(self) do |buffer|
		buffer.puts "Falcon Proxy v#{VERSION} taking flight!"
		buffer.puts "- Binding to: #{@options[:bind]}"
		buffer.puts "- To terminate: Ctrl-C or kill #{Process.pid}"
		buffer.puts "- To reload: kill -HUP #{Process.pid}"
		
		self.resolved_paths.each do |path|
			buffer.puts "- Loading configuration from #{path}"
		end
	end
	
	Async::Service::Controller.run(self.configuration)
end

#configurationObject



45
46
47
48
49
# File 'lib/falcon/command/proxy.rb', line 45

def configuration
	Configuration.for(
		self.environment(environments: super.environments)
	)
end

#endpoint(**options) ⇒ Object

The endpoint to bind to.



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

def endpoint(**options)
	Async::HTTP::Endpoint.parse(@options[:bind], timeout: @options[:timeout], **options)
end

#environment(**options) ⇒ Object



34
35
36
37
38
39
40
41
42
43
# File 'lib/falcon/command/proxy.rb', line 34

def environment(**options)
	Async::Service::Environment.new(Falcon::Environment::Proxy).with(
		root: Dir.pwd,
		name: self.class.name,
		verbose: self.parent&.verbose?,
		url: @options[:bind],
		timeout: @options[:timeout],
		**options
	)
end