egg_server/schedule/index.ts
zhaoyingbo 4932d6b8d6
All checks were successful
Egg CI/CD / build-image (push) Successful in 55s
Egg CI/CD / deploy (push) Successful in 30s
feat: 支持定时发送排名信息
2024-06-16 05:06:25 +00:00

14 lines
452 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { resetAccessToken } from "./accessToken";
import schedule from "node-schedule";
import sendRank from "./rank";
export const initSchedule = async () => {
// 定时任务每15分钟刷新一次token
schedule.scheduleJob("*/15 * * * *", resetAccessToken);
// 每天的早九到晚九点,每小时请求一次
schedule.scheduleJob("0 9-21 * * *", sendRank);
// 立即执行一次
resetAccessToken();
sendRank();
};