def main():
    """" Main execution code. """
    setup_dirs(detours_context['detours']['dirs'])

    config.dictConfig(detours_context['logging'])
    logger = getLogger(__name__)

    # COnfiguring constructors for custom tags
    yaml.add_constructor(u'!control_handler', control_handler_constructor)
    yaml.add_constructor(u'!io_handler', io_handler_constructor)
    yaml.add_constructor(u'!channel', channel_constructor)

    dispatch_layer = detours_context['detours']['dispatch_layer']

    with open(dispatch_layer, 'r') as f:
        handlers_conf = yaml.load(f)

    table = create_handlers(handlers_conf)
    reactor_dispatcher = Dispatcher(table)
    reactor_dispatcher.control_handler = handlers_conf['handlers']['control']
    reactor_dispatcher.dispatch_events()
    logger.info('Detours service terminated.')
    get_Zcontext().term()