Class: Falcon::Host
- Inherits:
-
Object
- Object
- Falcon::Host
- Defined in:
- lib/falcon/hosts.rb
Instance Method Summary collapse
- #assume_privileges(path) ⇒ Object
- #authority ⇒ Object
- #bound_endpoint ⇒ Object
- #endpoint ⇒ Object
-
#initialize(environment) ⇒ Host
constructor
A new instance of Host.
- #name ⇒ Object
- #root ⇒ Object
- #run(container) ⇒ Object
- #ssl_context ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(environment) ⇒ Host
Returns a new instance of Host.
32 33 34 35 |
# File 'lib/falcon/hosts.rb', line 32 def initialize(environment) @environment = environment.flatten @evaluator = @environment.evaluator end |
Instance Method Details
#assume_privileges(path) ⇒ Object
65 66 67 68 69 70 |
# File 'lib/falcon/hosts.rb', line 65 def assume_privileges(path) stat = File.stat(path) Process::GID.change_privilege(stat.gid) Process::UID.change_privilege(stat.uid) end |
#authority ⇒ Object
41 42 43 |
# File 'lib/falcon/hosts.rb', line 41 def @evaluator. end |
#bound_endpoint ⇒ Object
57 58 59 |
# File 'lib/falcon/hosts.rb', line 57 def bound_endpoint @evaluator.bound_endpoint end |
#endpoint ⇒ Object
45 46 47 |
# File 'lib/falcon/hosts.rb', line 45 def endpoint @evaluator.endpoint end |
#name ⇒ Object
37 38 39 |
# File 'lib/falcon/hosts.rb', line 37 def name "Falcon Host for #{self.}" end |
#run(container) ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/falcon/hosts.rb', line 72 def run(container) if @environment.include?(:server) bound_endpoint = self.bound_endpoint container.run(count: 1, name: self.name) do |task, instance| Async.logger.info(self) {"Starting application server..."} if root = self.root Dir.chdir(root) end server = @evaluator.server # Drop root privileges: assume_privileges(root) server.run task.children.each(&:wait) end end end |
#ssl_context ⇒ Object
49 50 51 |
# File 'lib/falcon/hosts.rb', line 49 def ssl_context @evaluator.ssl_context end |
#to_s ⇒ Object
61 62 63 |
# File 'lib/falcon/hosts.rb', line 61 def to_s "\#<#{self.class} #{@evaluator.}>" end |