Class: Falcon::Service::Server
- Inherits:
-
Async::Service::ManagedService
- Object
- Async::Service::ManagedService
- Falcon::Service::Server
- Defined in:
- lib/falcon/service/server.rb
Instance Method Summary collapse
-
#initialize ⇒ Server
constructor
A new instance of Server.
-
#run(instance, evaluator) ⇒ Object
Run the service logic.
-
#start ⇒ Object
Prepare the bound endpoint for the server.
-
#stop ⇒ Object
Close the bound endpoint.
Constructor Details
#initialize ⇒ Server
Returns a new instance of Server.
16 17 18 19 20 |
# File 'lib/falcon/service/server.rb', line 16 def initialize(...) super @bound_endpoint = nil end |
Instance Method Details
#run(instance, evaluator) ⇒ Object
Run the service logic.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/falcon/service/server.rb', line 40 def run(instance, evaluator) if evaluator.key?(:make_supervised_worker) Console.warn(self, "Async::Container::Supervisor is replaced by Async::Services::Supervisor, please update your service definition.") evaluator.make_supervised_worker(instance).run end server = evaluator.make_server(@bound_endpoint) Async do |task| server.run task.children.each(&:wait) end server end |
#start ⇒ Object
Prepare the bound endpoint for the server.
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/falcon/service/server.rb', line 23 def start @endpoint = @evaluator.endpoint Sync do @bound_endpoint = @endpoint.bound end Console.logger.info(self) {"Starting #{self.name} on #{@endpoint}"} super end |
#stop ⇒ Object
Close the bound endpoint.
69 70 71 72 73 74 75 76 77 78 |
# File 'lib/falcon/service/server.rb', line 69 def stop(...) if @bound_endpoint @bound_endpoint.close @bound_endpoint = nil end @endpoint = nil super end |