Start watcher loop, listening for config changes or failed hosts.

    Also starts the various service threads.

    VPC router watches for any changes in the config and updates/adds/deletes
    routes as necessary. If failed hosts are reported, routes are also updated
    as needed.

    This function starts a few working threads:

    - The watcher plugin to monitor for updated route specs.
    - A health monitor plugin for instances mentioned in the route spec.

    It then drops into a loop to receive messages from the health monitoring
    thread and watcher plugin and re-process the config if any failed IPs are
    reported.

    The loop itself is in its own function to facilitate easier testing.

def start_watcher(conf, watcher_plugin_class, health_plugin_class,
                  iterations=None, sleep_time=1):
    """
    Start watcher loop, listening for config changes or failed hosts.

    Also starts the various service threads.

    VPC router watches for any changes in the config and updates/adds/deletes
    routes as necessary. If failed hosts are reported, routes are also updated
    as needed.

    This function starts a few working threads:

    - The watcher plugin to monitor for updated route specs.
    - A health monitor plugin for instances mentioned in the route spec.

    It then drops into a loop to receive messages from the health monitoring
    thread and watcher plugin and re-process the config if any failed IPs are
    reported.

    The loop itself is in its own function to facilitate easier testing.

    """
    if CURRENT_STATE._stop_all:
        logging.debug("Not starting plugins: Global stop")
        return

    # Start the working threads (health monitor, config event monitor, etc.)
    # and return the thread handles and message queues in a thread-info dict.
    watcher_plugin, health_plugin = \
            start_plugins(conf, watcher_plugin_class, health_plugin_class,
                          sleep_time)
    CURRENT_STATE.add_plugin(watcher_plugin)
    CURRENT_STATE.add_plugin(health_plugin)

    # Start the loop to process messages from the monitoring
    # threads about any failed IP addresses or updated route specs.
    _event_monitor_loop(conf['region_name'], conf['vpc_id'],
                        watcher_plugin, health_plugin,
                        iterations, sleep_time, conf['route_recheck_interval'])

    # Stopping plugins and collecting all worker threads when we are done
    stop_plugins(watcher_plugin, health_plugin)