Example #1
0
 def _on_job_error(self, event):
     from service.job_service import JobService
     e = event.exception
     job_id = event.job_id
     logger.warn('定时任务%s发生错误,将被移除调度器' % job_id)
     logger.error(str(e))
     task = JobService.get_job(job_id)
     self.remove_job(task)
Example #2
0
 def _on_job_remove(self, event):
     from service.job_service import JobService
     job_id = event.job_id
     job = JobService.get_job(job_id)
     # 有自动删除的情况
     if job.status != job.Status.STOPPED.value:
         JobService.change_job_status(job_id, job.Status.STOPPED)
     logger.info('定时任务%s被移除了调度器,信息:%s' % (job_id, str(job)))
Example #3
0
 def _on_job_add(self, event):
     from service.job_service import JobService
     job_id = event.job_id
     job = JobService.get_job(job_id)
     # 有自动加入的情况
     if job.status != job.Status.RUNNING.value:
         JobService.change_job_status(job_id, job.Status.RUNNING)
         job.status = job.Status.RUNNING.value
     logger.info('定时任务%s加入了调度器,信息:%s' % (job_id, str(job)))
Example #4
0
 def _on_job_modify(self, event):
     from service.job_service import JobService
     job_id = event.job_id
     job = self._scheduler.get_job(job_id)
     if job.next_run_time is None:
         job = JobService.get_job(job_id)
         logger.info('定时任务%s已暂停,信息:%s' % (job_id, str(job)))
         if job.status != job.Status.SUSPENDED.value:
             JobService.change_job_status(job_id, job.Status.SUSPENDED)
     else:
         logger.info('定时任务%s被修改或重启了并正在运行中,信息:%s' % (job_id, str(job)))