Files
danmaku/schedule/schedule.js
2022-12-13 21:21:06 +08:00

42 lines
887 B
JavaScript
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.
const cron = require("node-cron");
const leancloud = require("../utils/leancloud");
const chai = require("chai");
const chaiHttp = require("chai-http");
const cf2dns = require("./cf2dns");
// const covidbook = require("./covidbook");
function subcache(app) {
console.log("Running Cron Jobsubcache");
chai.use(chaiHttp);
chai.request(app)
.get("/sub/cache")
.end((err, res) => {
leancloud.add("Schedule", {
name: "subcache",
result: res.text
});
console.log(res.text);
});
}
module.exports = (app) => {
//TODO 添加自动删除一个月前的日志
console.log("schedule.js loaded");
cron.schedule("0 */8 * * *", () => {
subcache(app);
});
cron.schedule("*/15 * * * *", () => {
cf2dns().then((result)=>{
leancloud.add("Schedule", {
name: "cf2dns",
result
});
});
// covidbook();
});
};
if (!module.parent) {
// covidbook();
}