Class: Falcon::Service::Application
- Inherits:
-
Proxy
show all
- Defined in:
- lib/falcon/service/application.rb
Instance Method Summary
collapse
Methods inherited from Proxy
#authority, #endpoint, #name, #protocol, #root, #scheme, #ssl_context
Methods inherited from Generic
#include?, #logger, #name, wrap
Constructor Details
#initialize(environment) ⇒ Application
Returns a new instance of Application.
31
32
33
34
35
|
# File 'lib/falcon/service/application.rb', line 31
def initialize(environment)
super
@bound_endpoint = nil
end
|
Instance Method Details
#middleware ⇒ Object
37
38
39
40
|
# File 'lib/falcon/service/application.rb', line 37
def middleware
@environment.evaluator.middleware
end
|
#preload! ⇒ Object
42
43
44
45
46
47
48
49
50
|
# File 'lib/falcon/service/application.rb', line 42
def preload!
if scripts = @evaluator.preload
scripts.each do |path|
Async.logger.info(self) {"Preloading #{path}..."}
full_path = File.expand_path(path, self.root)
load(full_path)
end
end
end
|
#setup(container) ⇒ Object
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
# File 'lib/falcon/service/application.rb', line 64
def setup(container)
protocol = self.protocol
scheme = self.scheme
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, protocol, scheme)
server.run
instance.ready!
task.children.each(&:wait)
end
end
super
end
|
#start ⇒ Object
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/falcon/service/application.rb', line 52
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!
super
end
|
#stop ⇒ Object
85
86
87
88
89
90
|
# File 'lib/falcon/service/application.rb', line 85
def stop
@bound_endpoint&.close
@bound_endpoint = nil
super
end
|