class Falcon::Services

Represents one or more services associated with a host.

The services model allows falcon to manage one more more service associated with a given host. Some examples of services include:

The list of services is typically generated from the user supplied `falcon.rb` configuration file, which is loaded into an immutable {Configuration} instance, which is mapped into a list of services.

Public Class Methods

new(configuration) click to toggle source

Initialize the services from the given configuration.

@parameter configuration [Configuration]

# File lib/falcon/services.rb, line 39
def initialize(configuration)
        @named = {}
        
        configuration.each(:service) do |environment|
                service = Service::Generic.wrap(environment)
                
                add(service)
        end
end

Public Instance Methods

add(service) click to toggle source

Add a named service.

@parameter service [Service]

# File lib/falcon/services.rb, line 57
def add(service)
        @named[service.name] = service
end
each(&block) click to toggle source

Enumerate all named services.

# File lib/falcon/services.rb, line 50
def each(&block)
        @named.each_value(&block)
end
setup(container) click to toggle source

Setup all named services into the given container.

@parameter container [Async::Container::Generic]

# File lib/falcon/services.rb, line 72
def setup(container)
        @named.each do |name, service|
                Console.logger.debug(self) {"Setup #{name} into #{container}..."}
                service.setup(container)
        end
        
        return container
end
start() click to toggle source

Start all named services.

# File lib/falcon/services.rb, line 62
def start
        @named.each do |name, service|
                Console.logger.debug(self) {"Starting #{name}..."}
                service.start
        end
end
stop() click to toggle source

Stop all named services.

# File lib/falcon/services.rb, line 82
def stop
        failed = false
        
        @named.each do |name, service|
                Console.logger.debug(self) {"Stopping #{name}..."}
                
                begin
                        service.stop
                rescue
                        failed = true
                        Console.logger.error(self, $!)
                end
        end
        
        return failed
end