Class: Falcon::Command::Host

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

Overview

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

Manages a Falcon::Controller::Host instance which is responsible for running applications in a production environment.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#pathsObject (readonly)

One or more paths to the configuration files.



24
# File 'lib/falcon/command/host.rb', line 24

many :paths, "Service configuration paths.", default: ["falcon.rb"]

Instance Method Details

#callObject

Prepare the environment and run the controller.



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/falcon/command/host.rb', line 49

def call
	Console.logger.info(self) do |buffer|
		buffer.puts "Falcon Host v#{VERSION} taking flight!"
		buffer.puts "- Configuration: #{@paths.join(', ')}"
		buffer.puts "- To terminate: Ctrl-C or kill #{Process.pid}"
		buffer.puts "- To reload: kill -HUP #{Process.pid}"
	end
	
	begin
		Bundler.require(:preload)
	rescue Bundler::GemfileNotFound
		# Ignore.
	end
	
	if GC.respond_to?(:compact)
		GC.compact
	end
	
	self.controller.run
end

#configurationObject

Generate a configuration based on the specified #paths.



32
33
34
35
36
37
38
39
40
41
# File 'lib/falcon/command/host.rb', line 32

def configuration
	configuration = Configuration.new
	
	@paths.each do |path|
		path = File.expand_path(path)
		configuration.load_file(path)
	end
	
	return configuration
end

#container_classObject

The container class to use.



27
28
29
# File 'lib/falcon/command/host.rb', line 27

def container_class
	Async::Container.best_container_class
end

#controllerObject

Prepare a new controller for the command.



44
45
46
# File 'lib/falcon/command/host.rb', line 44

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