Class: Async::Service::Controller
- Inherits:
-
Container::Controller
- Object
- Container::Controller
- Async::Service::Controller
- Defined in:
- lib/async/service/controller.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(services, **options) ⇒ Controller
constructor
A new instance of Controller.
- #services ⇒ Object
-
#setup(container) ⇒ Object
Setup all services into the given container.
-
#start ⇒ Object
Start all named services.
-
#stop(graceful = true) ⇒ Object
Stop all named services.
Constructor Details
#initialize(services, **options) ⇒ Controller
Returns a new instance of Controller.
35 36 37 38 39 |
# File 'lib/async/service/controller.rb', line 35 def initialize(services, **) super(**) @services = services end |
Class Method Details
.run(configuration, **options) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/async/service/controller.rb', line 27 def self.run(configuration, **) controller = Async::Service::Controller.new(configuration.services.to_a, **) self.warmup controller.run end |
.warmup ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/async/service/controller.rb', line 11 def self.warmup begin require 'bundler' Bundler.require(:preload) rescue Bundler::GemfileNotFound, LoadError # Ignore. end if Process.respond_to?(:warmup) Process.warmup elsif GC.respond_to?(:compact) 3.times{GC.start} GC.compact end end |
Instance Method Details
#services ⇒ Object
43 44 45 |
# File 'lib/async/service/controller.rb', line 43 def services @services end |
#setup(container) ⇒ Object
Setup all services into the given container.
57 58 59 60 61 62 63 64 65 |
# File 'lib/async/service/controller.rb', line 57 def setup(container) super @services.each do |service| service.setup(container) end return container end |
#start ⇒ Object
Start all named services.
46 47 48 49 50 51 52 |
# File 'lib/async/service/controller.rb', line 46 def start @services.each do |service| service.start end super end |
#stop(graceful = true) ⇒ Object
Stop all named services.
68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/async/service/controller.rb', line 68 def stop(graceful = true) @services.each do |service| begin service.stop rescue => error Console.error(self, error) end end super end |