Class: Falcon::Services
- Inherits:
-
Object
- Object
- Falcon::Services
- Defined in:
- lib/falcon/services.rb
Instance Method Summary collapse
- #add(service) ⇒ Object
- #each(&block) ⇒ Object
-
#initialize(configuration) ⇒ Services
constructor
A new instance of Services.
- #setup(container) ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(configuration) ⇒ Services
Returns a new instance of Services.
25 26 27 28 29 30 31 32 33 |
# File 'lib/falcon/services.rb', line 25 def initialize(configuration) @named = {} configuration.each(:service) do |environment| service = Service::Generic.wrap(environment) add(service) end end |
Instance Method Details
#add(service) ⇒ Object
39 40 41 |
# File 'lib/falcon/services.rb', line 39 def add(service) @named[service.name] = service end |
#each(&block) ⇒ Object
35 36 37 |
# File 'lib/falcon/services.rb', line 35 def each(&block) @named.each_value(&block) end |
#setup(container) ⇒ Object
50 51 52 53 54 55 56 57 |
# File 'lib/falcon/services.rb', line 50 def setup(container) @named.each do |name, service| Async.logger.debug(self) {"Setup #{name} into #{container}..."} service.setup(container) end return container end |
#start ⇒ Object
43 44 45 46 47 48 |
# File 'lib/falcon/services.rb', line 43 def start @named.each do |name, service| Async.logger.debug(self) {"Starting #{name}..."} service.start end end |
#stop ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/falcon/services.rb', line 59 def stop failed = false @named.each do |name, service| Async.logger.debug(self) {"Stopping #{name}..."} begin service.stop rescue failed = true Async.logger.error(self, $!) end end return failed end |