Пример #1
0
    def run(self) -> None:
        # logger.warning('This is a development server. Do not use it in a production deployment.')
        try:
            for task_name in self.deploy_cluster:
                try:
                    schedule.every(self.crontab['action']).minutes.do(
                        self.push_task, task_name=task_name)
                    schedule.every(self.crontab['refresh']).minutes.do(
                        self.rc.refresh,
                        key_name=REDIS_SECRET_KEY.format(task_name))
                    logger.info(
                        f"start {task_name}/crontab:{self.crontab['action']} minutes"
                    )

                except schedule.IntervalError:
                    logger.error('interval set error')

                self.crontab['action'] += 5

            while True:
                schedule.run_pending()
                time.sleep(1)

        except Exception as err:
            logger.exception('Exception occurred ||{}'.format(err))
            noticer.send_email(text_body='{}'.format(err), to='self')
        except KeyboardInterrupt as err:
            logger.stop('Forced stop ||{}'.format(err))
Пример #2
0
    def run(self) -> None:
        # logger.warning('This is a development server. Do not use it in a production deployment.')
        try:
            for task_name in self.deploy_cluster:
                try:
                    schedule.every(self.crontab['action']).minutes.do(self.push_task, task_name=task_name)
                    if ENABLE_DDT:
                        schedule.every(self.crontab['refresh']).minutes.do(self.rc.refresh,
                                                                           key_name=REDIS_SECRET_KEY.format(task_name))
                        logger.success(f"START DDT -- {task_name}")
                    else:
                        logger.warning(f'Not Authorized -- DDT({task_name})')
                    logger.success(f"START TASK -- {task_name}/crontab:{self.crontab['action']} minutes")

                except schedule.IntervalError:
                    logger.error('interval set error')

                # self.crontab['action'] += 5

            while True:
                schedule.run_pending()
                time.sleep(1)

        except Exception as err:
            logger.exception('Exception occurred ||{}'.format(err))
            noticer.send_email(msg='{}'.format(err), to_='self')
        except KeyboardInterrupt as err:
            logger.stop('Forced stop ||{}'.format(err))