Example #1
0
  def __init__(self, config):
    # Logging.
    self.logger = logging.getLogger(__name__)

    # The overall configuration.
    self.config = config

    # The proxy being used to talk to HAProxy.
    self.proxy = Proxy()

    # The components, by name.
    self.components = {}

    # Build the components map.
    for component_config in config.components:
      self.components[component_config.name] = Component(self, component_config)

    # Create the lock for the watcher thread and the notification event.
    self.watcher_lock = threading.Lock()
    self.watcher_event = threading.Event()

    # The set of containers which should be terminated by the terminating workers.
    self.containers_to_terminate = Queue()

    # Start the thread used to watch and stop containers that are no longer needed.
    self.pool = ThreadPool()

    # Place to collect the results of the monitor
    self.monitor_futures = Queue()