def main():
    my_config = get_config()

    new_synapse_config = generate_configuration(my_config,
                                                get_zookeeper_topology(),
                                                get_all_namespaces())

    with tempfile.NamedTemporaryFile() as tmp_file:
        new_synapse_config_path = tmp_file.name
        with open(new_synapse_config_path, 'w') as fp:
            json.dump(new_synapse_config,
                      fp,
                      sort_keys=True,
                      indent=4,
                      separators=(',', ': '))

        # Match permissions that puppet expects
        os.chmod(new_synapse_config_path, 0644)

        # Restart synapse if the config files differ
        should_restart = not filecmp.cmp(new_synapse_config_path,
                                         my_config['config_file'])

        # Always swap new config file into place.  Our monitoring system
        # checks the config['config_file'] file age to ensure that it is
        # continually being updated.
        shutil.copy(new_synapse_config_path, my_config['config_file'])

        if should_restart:
            subprocess.check_call(SYNAPSE_RESTART_COMMAND)
def main():
    my_config = get_config()

    new_synapse_config = generate_configuration(
        my_config, get_zookeeper_topology(), get_all_namespaces()
    )

    with tempfile.NamedTemporaryFile() as tmp_file:
        new_synapse_config_path = tmp_file.name
        with open(new_synapse_config_path, 'w') as fp:
            json.dump(new_synapse_config, fp, sort_keys=True, indent=4, separators=(',', ': '))

        # Match permissions that puppet expects
        os.chmod(new_synapse_config_path, 0644)

        # Restart synapse if the config files differ
        should_restart = not filecmp.cmp(new_synapse_config_path, my_config['config_file'])

        # Always swap new config file into place.  Our monitoring system
        # checks the config['config_file'] file age to ensure that it is
        # continually being updated.
        shutil.copy(new_synapse_config_path, my_config['config_file'])

        if should_restart:
            subprocess.check_call(SYNAPSE_RESTART_COMMAND)
def main():
    strings = []
    for full_name, config in marathon_tools.get_all_namespaces():
        if 'proxy_port' in config:
            strings.append('{}:{}'.format(full_name, config['proxy_port']))
    strings = sorted(strings)
    paasta_print("synapse_srv_namespaces=" + ','.join(strings))
    sys.exit(0)
def main():
    strings = []
    for full_name, config in marathon_tools.get_all_namespaces():
        if 'proxy_port' in config:
            strings.append('%s:%s' % (full_name, config['proxy_port']))
    strings = sorted(strings)
    print "synapse_srv_namespaces=" + ','.join(strings)
    sys.exit(0)
def main():
    strings = []
    for full_name, config in marathon_tools.get_all_namespaces():
        if 'proxy_port' in config:
            strings.append('%s:%s' % (full_name, config['proxy_port']))
    strings = sorted(strings)
    print "synapse_srv_namespaces=" + ','.join(strings)
    sys.exit(0)
def main():
    strings = []
    for full_name, config in marathon_tools.get_all_namespaces():
        if "proxy_port" in config:
            strings.append("{}:{}".format(full_name, config["proxy_port"]))
    strings = sorted(strings)
    paasta_print("synapse_srv_namespaces=" + ",".join(strings))
    sys.exit(0)
def generate_configuration():
    service_data = get_all_namespaces()
    config = {}
    for (name, data) in service_data:
        proxy_port = data.get("proxy_port")
        if proxy_port is None:
            continue
        config[name] = {"host": YOCALHOST, "port": int(proxy_port)}
    return config
Example #8
0
def generate_configuration():
    service_data = get_all_namespaces()

    config = {}
    for (name, data) in service_data:
        proxy_port = data.get("proxy_port")
        if proxy_port is None:
            continue
        config[name.encode("utf-8")] = {b"host": YOCALHOST, b"port": int(proxy_port)}

    return config
Example #9
0
def generate_configuration():
    service_data = get_all_namespaces()
    config = {}
    for (name, data) in service_data:
        proxy_port = data.get('proxy_port')
        if proxy_port is None:
            continue
        config[name.encode('utf-8')] = {
            b'host': YOCALHOST,
            b'port': int(proxy_port),
        }
    return config
Example #10
0
def generate_configuration():
    service_data = get_all_namespaces()

    config = {}
    for (name, data) in service_data:
        proxy_port = data.get('proxy_port')
        if proxy_port is None:
            continue
        config[name] = {
            'host': YOCALHOST,
            'port': int(proxy_port),
        }

    return config
Example #11
0
def main() -> None:
    my_config = get_config(
        os.environ.get('SYNAPSE_TOOLS_CONFIG_PATH',
                       '/etc/synapse/synapse-tools.conf.json'))

    # Allow overriding the SOA directory
    soa_dir = os.environ.get(
        'SOA_DIR',
        DEFAULT_SOA_DIR,
    )

    new_synapse_config = generate_configuration(
        my_config,
        get_zookeeper_topology(my_config['zookeeper_topology_path']),
        get_all_namespaces(soa_dir),
    )

    with tempfile.NamedTemporaryFile() as tmp_file:
        new_synapse_config_path = tmp_file.name
        with open(new_synapse_config_path, 'w') as fp:
            json.dump(new_synapse_config,
                      fp,
                      sort_keys=True,
                      indent=4,
                      separators=(',', ': '))

        # Match permissions that puppet expects
        os.chmod(new_synapse_config_path, 0o644)

        # Restart synapse if the config files differ
        should_restart = not filecmp.cmp(new_synapse_config_path,
                                         my_config['config_file'])

        # Always swap new config file into place.  Our monitoring system
        # checks the config['config_file'] file age to ensure that it is
        # continually being updated.
        shutil.copy(new_synapse_config_path, my_config['config_file'])

        if should_restart:
            # backwards compatibility for synapse_restart_command
            # Note that it's preferable to use synapse_command
            if 'synapse_restart_command' in my_config:
                subprocess.check_call(my_config['synapse_restart_command'])
            else:
                # Use stop + start so that we re-read the init file
                # This is useful, for example, to ensure Synapse has good
                # limits on file descriptors (which means HAProxy will)
                cmd = my_config['synapse_command']
                subprocess.check_call(cmd + ['stop'])
                subprocess.check_call(cmd + ['start'])