Пример #1
0
    def run(self):

        self.start_ts = int(time.time())

        self.process = Subprocess(self.cmd,
                                  stdout=Subprocess.STREAM,
                                  stderr=Subprocess.STREAM,
                                  env=self.env,
                                  io_loop=self.io_loop)

        # create db record
        s = Session()
        s.begin()
        command = minion.db.commands.Command(
            uid=self.uid,
            pid=self.process.pid,
            command=self.cmd_str,
            start_ts=int(time.time()),
            task_id=self.params.get('task_id'),
            job_id=self.params.get('job_id'),
        )

        s.update_ts = int(time.time())
        s.add(command)
        s.commit()

        self.watcher = self.watch(command)

        self.command = command
Пример #2
0
    def run(self):

        self.start_ts = int(time.time())

        self.process = Subprocess(self.cmd,
                                  stdout=Subprocess.STREAM,
                                  stderr=Subprocess.STREAM,
                                  env=self.env,
                                  io_loop=self.io_loop)

        # create db record
        s = Session()
        s.begin()
        command = minion.db.commands.Command(
            uid=self.uid,
            pid=self.process.pid,
            command=self.cmd_str,
            start_ts=int(time.time()),
            task_id=self.params.get('task_id'),
        )

        s.update_ts = int(time.time())
        s.add(command)
        s.commit()

        self.watcher = self.watch(command)

        self.command = command
Пример #3
0
    def run(self):

        self.start_ts = int(time.time())

        # create db record
        s = Session()
        s.begin()
        command = minion.db.commands.Command(
            uid=self.uid,
            pid=None,
            command=self.COMMAND,
            start_ts=self.start_ts,
            task_id=self.params.get('task_id'),
            job_id=self.params.get('job_id'),
        )

        s.update_ts = int(time.time())
        s.add(command)
        s.commit()

        try:
            yield self.execute()
        except Exception as e:
            cmd_logger.exception('Command execution failed',
                                 extra=self.log_extra)
            self.error = e

        self.finish_ts = int(time.time())

        s.begin()
        try:
            command.progress = 1.0
            command.exit_code = 1 if self.error else 0
            command.command_code = 1 if self.error else 0
            command.finish_ts = self.finish_ts
            command.artifacts = json.dumps(self.artifacts)
            s.add(command)
            s.commit()
        except Exception as e:
            cmd_logger.exception('Failed to update db command',
                                 extra=self.log_extra)
            s.rollback()
Пример #4
0
    def run(self):

        self.start_ts = int(time.time())

        # create db record
        s = Session()
        s.begin()
        command = minion.db.commands.Command(
            uid=self.uid,
            pid=None,
            command=self.COMMAND,
            start_ts=self.start_ts,
            task_id=self.params.get('task_id'),
            job_id=self.params.get('job_id'),
        )

        s.update_ts = int(time.time())
        s.add(command)
        s.commit()

        try:
            yield self.execute()
        except Exception as e:
            cmd_logger.exception('Command execution failed', extra=self.log_extra)
            self.error = e

        self.finish_ts = int(time.time())

        s.begin()
        try:
            command.progress = 1.0
            command.exit_code = 1 if self.error else 0
            command.command_code = 1 if self.error else 0
            command.finish_ts = self.finish_ts
            command.artifacts = json.dumps(self.artifacts)
            s.add(command)
            s.commit()
        except Exception as e:
            cmd_logger.exception('Failed to update db command', extra=self.log_extra)
            s.rollback()