Example #1
0
    def start_service(self, name, conf_file):
        port_num = CONF.congressha.replica_port
        out = tempfile.NamedTemporaryFile(mode='w',
                                          suffix='.out',
                                          prefix='congress-%s-%d-' %
                                          (name, port_num),
                                          dir='/tmp',
                                          delete=False)

        err = tempfile.NamedTemporaryFile(mode='w',
                                          suffix='.err',
                                          prefix='congress-%s-%d-' %
                                          (name, port_num),
                                          dir='/tmp',
                                          delete=False)

        service = '--' + name
        node = name + '-replica-node'
        args = [
            '/usr/bin/python', 'bin/congress-server', service, '--node-id',
            node, '--config-file', conf_file
        ]

        p = subprocess.Popen(args,
                             stdout=out,
                             stderr=err,
                             cwd=helper.root_path())
        return p
Example #2
0
    def start_replica(self, port_num):
        self._prepare_replica(port_num)
        f = tempfile.NamedTemporaryFile(mode='w', suffix='.conf',
                                        prefix='congress%d-' % port_num,
                                        dir='/tmp', delete=False)
        conf_file = f.name
        template = open('/etc/congress/congress.conf')
        conf = template.read()

        # Add 'bind_port' and 'datasource_sync_period' to conf file.
        index = conf.find('[DEFAULT]') + len('[DEFAULT]\n')
        conf = (conf[:index] + 'bind_port = %d\n' % port_num +
                'datasource_sync_period = 5\n' + conf[index:])
        sindex = conf.find('signing_dir')
        conf = conf[:sindex] + '#' + conf[sindex:]
        conf = re.sub(r'node_id[ ]*=[ ]*[a-zA-Z_-]+[ ]*',
                      'node_id = replica-node', conf)
        f.write(conf)
        f.close()

        args = ['/usr/bin/python',
                'bin/congress-server',
                '--config-file',
                conf_file]
        out = tempfile.NamedTemporaryFile(mode='w', suffix='.out',
                                          prefix='congress%d-' % port_num,
                                          dir='/tmp', delete=False)
        err = tempfile.NamedTemporaryFile(mode='w', suffix='.err',
                                          prefix='congress%d-' % port_num,
                                          dir='/tmp', delete=False)
        p = subprocess.Popen(args, stdout=out, stderr=err,
                             cwd=helper.root_path())

        assert port_num not in self.replicas
        self.replicas[port_num] = (p, conf_file)
Example #3
0
    def start_service(self, name, conf_file):
        service = '--' + name
        node = name + '-replica-node'
        args = [
            'bin/congress-server', service, '--node-id', node, '--config-file',
            conf_file
        ]

        p = subprocess.Popen(args,
                             stdout=subprocess.PIPE,
                             stderr=subprocess.STDOUT,
                             cwd=helper.root_path())
        return p
Example #4
0
    def start_service(self, name, conf_file):
        port_num = CONF.congressha.replica_port
        out = tempfile.NamedTemporaryFile(
            mode='w', suffix='.out',
            prefix='congress-%s-%d-' % (name, port_num),
            dir='/tmp', delete=False)

        err = tempfile.NamedTemporaryFile(
            mode='w', suffix='.err',
            prefix='congress-%s-%d-' % (name, port_num),
            dir='/tmp', delete=False)

        service = '--' + name
        node = name + '-replica-node'
        args = ['/usr/bin/python', 'bin/congress-server', service,
                '--node-id', node, '--config-file', conf_file]

        p = subprocess.Popen(args, stdout=out, stderr=err,
                             cwd=helper.root_path())
        return p