Пример #1
0
def run():
    vhost = utils.parse_vhost(VIRTUAL_HOST, os.environ)
    backend_routes = utils.parse_backend_routes(os.environ)
    cfg = cfg_calc(backend_routes, vhost)
    cfg_text = cfg_to_text(cfg)
    logger.info("HAProxy configuration:\n%s" % cfg_text)
    cfg_save(cfg_text, CONFIG_FILE)

    logger.info("Launching HAProxy")
    p = subprocess.Popen(HAPROXY_CMD)
    p.wait()
Пример #2
0
def run():
    vhost = utils.parse_vhost(VIRTUAL_HOST, os.environ)
    backend_routes = utils.parse_backend_routes(os.environ)
    cfg = cfg_calc(backend_routes, vhost)
    cfg_text = cfg_to_text(cfg)
    logger.info("HAProxy configuration:\n%s" % cfg_text)
    cfg_save(cfg_text, CONFIG_FILE)

    logger.info("Launching HAProxy")
    p = subprocess.Popen(HAPROXY_CMD)
    p.wait()
Пример #3
0
def run_tutum(container_uri=TUTUM_CONTAINER_API_URI):
    global PREVIOUS_CFG_TEXT, HAPROXY_CURRENT_SUBPROCESS
    # logger.info("Fetching HAProxy container details through REST Api")
    container = fetch_tutum_obj(container_uri)

    envvars = {}
    for pair in container.container_envvars:
        envvars[pair['key']] = pair['value']
    vhost = utils.parse_vhost(VIRTUAL_HOST, envvars)
    backend_routes = utils.parse_backend_routes_tutum(container.linked_to_container)

    cfg = cfg_calc(backend_routes, vhost)
    cfg_text = cfg_to_text(cfg)
    if PREVIOUS_CFG_TEXT != cfg_text:
        logger.info("HAProxy configuration is updated:\n%s" % cfg_text)
        cfg_save(cfg_text, CONFIG_FILE)
        PREVIOUS_CFG_TEXT = cfg_text
        HAPROXY_CURRENT_SUBPROCESS = reload_haproxy(HAPROXY_CURRENT_SUBPROCESS)
Пример #4
0
def run_tutum(container_uri=TUTUM_CONTAINER_API_URI):
    global PREVIOUS_CFG_TEXT, HAPROXY_CURRENT_SUBPROCESS
    # logger.info("Fetching HAProxy container details through REST Api")
    container = fetch_tutum_obj(container_uri)

    envvars = {}
    for pair in container.container_envvars:
        envvars[pair['key']] = pair['value']
    vhost = utils.parse_vhost(VIRTUAL_HOST, envvars)
    backend_routes = utils.parse_backend_routes_tutum(
        container.linked_to_container)

    cfg = cfg_calc(backend_routes, vhost)
    cfg_text = cfg_to_text(cfg)
    if PREVIOUS_CFG_TEXT != cfg_text:
        logger.info("HAProxy configuration is updated:\n%s" % cfg_text)
        cfg_save(cfg_text, CONFIG_FILE)
        PREVIOUS_CFG_TEXT = cfg_text
        HAPROXY_CURRENT_SUBPROCESS = reload_haproxy(HAPROXY_CURRENT_SUBPROCESS)