def exposed_event_execute(exec_id, interface_id, job_id, server_dir, server_script, return_code, params, status): """接受事件任务""" # 添加至调度器 run_id = 'event_%s_%s_%s' % (exec_id, interface_id, job_id) kwargs = { 'exec_id': exec_id, 'interface_id': interface_id, 'job_id': job_id, 'server_dir': server_dir, 'server_script': server_script, 'return_code': return_code, 'params': params, 'status': status } log.info('接收任务: %s, run_id: %s' % (str(kwargs), run_id)) # 添加调度任务 next_run_time = datetime.datetime.now() + datetime.timedelta(seconds=2) try: # 查询任务是否存在 run_job = SchedulerModel.get_scheduler_by_id(db.etl_db, run_id, config.exec.table_name) if run_job: return {'status': False, 'msg': '该任务已在运行中'} # scheduler.add_job(id=run_id, func=start_job, # args=(exec_id, job_id, server_dir, server_script, status), trigger='interval', seconds=3) scheduler.add_job(id=run_id, func=start_job, args=( exec_id, interface_id, job_id, server_dir, server_script, return_code, params, status), next_run_time=next_run_time) return {'status': True, 'msg': '任务已开始运行'} except Exception as e: return {'status': False, 'msg': e}
def add_event(run_id, ftp_event_id, minute, hour): """新增事件""" scheduler.add_job( id=run_id, func=get_event_job, args=(ftp_event_id, ), trigger='cron', minute=minute, hour=hour, )
def add_job(run_id, dispatch_id, minute, hour, day, month, week): """添加任务""" scheduler.add_job( id=run_id, func=get_dispatch_job, args=(dispatch_id,), trigger='cron', minute=minute, hour=hour, day=day, month=month, week=week )
def add_job(run_id, dispatch_id, minute, hour, day, month, week): """添加任务""" scheduler.add_job( id=run_id, func=get_dispatch_job, args=(dispatch_id, ), trigger='cron', minute=minute, hour=hour, day=day, month=month, week=week, coalesce=True, max_instances=config.schedule.max_instances, misfire_grace_time=config.schedule.misfire_grace_time)