| 49 | |
| 50 | # Github 监控任务下发 |
| 51 | def github_cron_run(item): |
| 52 | task_data = { |
| 53 | "name": "GitHub监控-" + item["name"], |
| 54 | "keyword": item["keyword"], |
| 55 | "start_time": "-", |
| 56 | "end_time": "-", |
| 57 | "github_scheduler_id": str(item["_id"]), |
| 58 | "status": TaskStatus.WAITING, |
| 59 | } |
| 60 | # 下发周期运行任务 |
| 61 | submit_github_task(task_data=task_data, action=CeleryAction.GITHUB_TASK_MONITOR) |
| 62 | |
| 63 | item["run_number"] = item["run_number"] + 1 |
| 64 | item["last_run_date"] = utils.curr_date() |
| 65 | item["last_run_time"] = int(time.time()) |
| 66 | entry = CronTab(item["cron"]) |
| 67 | now_time = time.time() + 61 |
| 68 | next_sec = entry.next(now=now_time, default_utc=False) |
| 69 | item["next_run_date"] = utils.time2date(now_time + next_sec - 60) |
| 70 | |
| 71 | query = { |
| 72 | "_id": item["_id"] |
| 73 | } |
| 74 | utils.conn_db('github_scheduler').find_one_and_replace(query, item) |
| 75 | |
| 76 | |
| 77 | # Github 监控任务调度,有个循环 |