Class: Falcon::Service::Application
- Defined in:
- lib/falcon/service/application.rb
Instance Method Summary collapse
- #authority ⇒ Object
- #endpoint ⇒ Object
-
#initialize(environment) ⇒ Application
constructor
A new instance of Application.
- #middleware ⇒ Object
- #name ⇒ Object
- #preload! ⇒ Object
- #protocol ⇒ Object
- #root ⇒ Object
- #scheme ⇒ Object
- #setup(container) ⇒ Object
- #ssl_context ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
- #to_s ⇒ Object
Methods inherited from Generic
Constructor Details
#initialize(environment) ⇒ Application
Returns a new instance of Application.
29 30 31 32 33 |
# File 'lib/falcon/service/application.rb', line 29 def initialize(environment) super @bound_endpoint = nil end |
Instance Method Details
#authority ⇒ Object
39 40 41 |
# File 'lib/falcon/service/application.rb', line 39 def @evaluator. end |
#endpoint ⇒ Object
43 44 45 |
# File 'lib/falcon/service/application.rb', line 43 def endpoint @evaluator.endpoint end |
#middleware ⇒ Object
55 56 57 |
# File 'lib/falcon/service/application.rb', line 55 def middleware @evaluator.middleware end |
#name ⇒ Object
35 36 37 |
# File 'lib/falcon/service/application.rb', line 35 def name "#{self.class} for #{self.}" end |
#preload! ⇒ Object
67 68 69 70 71 72 73 74 75 |
# File 'lib/falcon/service/application.rb', line 67 def preload! if scripts = @evaluator.preload scripts.each do |path| Async.logger.info(self) {"Preloading #{path}..."} full_path = File.(path, self.root) load(full_path) end end end |
#protocol ⇒ Object
59 60 61 |
# File 'lib/falcon/service/application.rb', line 59 def protocol endpoint.protocol end |
#root ⇒ Object
51 52 53 |
# File 'lib/falcon/service/application.rb', line 51 def root @evaluator.root end |
#scheme ⇒ Object
63 64 65 |
# File 'lib/falcon/service/application.rb', line 63 def scheme endpoint.scheme end |
#setup(container) ⇒ Object
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/falcon/service/application.rb', line 91 def setup(container) container.run(name: self.name, restart: true) do |instance| Async(logger: logger) do |task| Async.logger.info(self) {"Starting application server for #{self.root}..."} server = Server.new(self.middleware, @bound_endpoint, self.protocol, self.scheme) server.run instance.ready! task.children.each(&:wait) end end end |
#ssl_context ⇒ Object
47 48 49 |
# File 'lib/falcon/service/application.rb', line 47 def ssl_context @evaluator.ssl_context end |
#start ⇒ Object
81 82 83 84 85 86 87 88 89 |
# File 'lib/falcon/service/application.rb', line 81 def start Async.logger.info(self) {"Binding to #{self.endpoint}..."} @bound_endpoint = Async::Reactor.run do Async::IO::SharedEndpoint.bound(self.endpoint) end.wait preload! end |
#stop ⇒ Object
107 108 109 110 |
# File 'lib/falcon/service/application.rb', line 107 def stop @bound_endpoint&.close @bound_endpoint = nil end |
#to_s ⇒ Object
77 78 79 |
# File 'lib/falcon/service/application.rb', line 77 def to_s "#{self.class} #{@evaluator.}" end |