示例#1
0
    def start_replica(self, replica_id):
        """
        Start a replica if it isn't already started.
        Otherwise raise an AlreadyStoppedError.
        """
        with log.start_action(action_type="start_replica"):
            stdout_file = None
            stderr_file = None
            if os.environ.get('KEEP_APOLLO_LOGS', "").lower() in ["true", "on"]:
                try:
                    os.mkdir(f"/tmp/apollo/{self.current_test}/")
                except FileExistsError:
                    pass
                stdout_file = open("/tmp/apollo/{}/stdout_{}.log".format(self.current_test, replica_id), 'a+')
                stderr_file = open("/tmp/apollo/{}/stderr_{}.log".format(self.current_test, replica_id), 'a+')

                stdout_file.write("############################################\n")
                stdout_file.flush()
                stderr_file.write("############################################\n")
                stderr_file.flush()

                self.open_fds[replica_id] = (stdout_file, stderr_file)

            if replica_id in self.procs:
                raise AlreadyRunningError(replica_id)

            if self.is_existing and self.config.stop_replica_cmd is not None:
                self.procs[replica_id] = self._start_external_replica(replica_id)
            else:
                self.procs[replica_id] = subprocess.Popen(
                                            self.start_replica_cmd(replica_id),
                                            stdout=stdout_file,
                                            stderr=stderr_file,
                                            close_fds=True)
示例#2
0
 def start_replica(self, replica_id):
     """
     Start a replica if it isn't already started.
     Otherwise raise an AlreadyStoppedError.
     """
     if replica_id in self.procs:
         raise AlreadyRunningError(replica_id)
     cmd = self.start_replica_cmd(replica_id)
     self.procs[replica_id] = subprocess.Popen(cmd, close_fds=True)
示例#3
0
    def start_replica(self, replica_id):
        """
        Start a replica if it isn't already started.
        Otherwise raise an AlreadyStoppedError.
        """
        if replica_id in self.procs:
            raise AlreadyRunningError(replica_id)

        if self.is_existing and self.config.stop_replica_cmd is not None:
            self.procs[replica_id] = self._start_external_replica(replica_id)
        else:
            self.procs[replica_id] = subprocess.Popen(
                self.start_replica_cmd(replica_id), close_fds=True)