Class: Falcon::Services

Inherits:
Object
  • Object
show all
Defined in:
lib/falcon/services.rb

Instance Method Summary collapse

Constructor Details

#initialize(configuration) ⇒ Services



27
28
29
30
31
32
33
34
35
# File 'lib/falcon/services.rb', line 27

def initialize(configuration)
  @named = {}
  
  configuration.each(:service) do |environment|
    service = Service::Generic.wrap(environment)
    
    add(service)
  end
end

Instance Method Details

#add(service) ⇒ Object



41
42
43
# File 'lib/falcon/services.rb', line 41

def add(service)
  @named[service.name] = service
end

#each(&block) ⇒ Object



37
38
39
# File 'lib/falcon/services.rb', line 37

def each(&block)
  @named.each_value(&block)
end

#setup(container) ⇒ Object



52
53
54
55
56
57
58
59
# File 'lib/falcon/services.rb', line 52

def setup(container)
  @named.each do |name, service|
    Async.logger.debug(self) {"Setup #{name} into #{container}..."}
    service.setup(container)
  end
  
  return container
end

#startObject



45
46
47
48
49
50
# File 'lib/falcon/services.rb', line 45

def start
  @named.each do |name, service|
    Async.logger.debug(self) {"Starting #{name}..."}
    service.start
  end
end

#stopObject



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/falcon/services.rb', line 61

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