forked from mirror/MCSManager
新增 - 完善计划任务辅助器
This commit is contained in:
parent
ff75380386
commit
6e3aa9c6cd
@ -3,7 +3,7 @@ const schedule = require("node-schedule");
|
||||
MCSERVER.Schedule = {};
|
||||
MCSERVER.Schedule.container = {};
|
||||
|
||||
|
||||
//循环型任务
|
||||
module.exports.createScheduleJob = (id, time, callback) => {
|
||||
let mask = MCSERVER.Schedule.container[id] = schedule.scheduleJob(time, (fireDate) => {
|
||||
let res = callback();
|
||||
@ -13,9 +13,7 @@ module.exports.createScheduleJob = (id, time, callback) => {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//计次型任务
|
||||
module.exports.createScheduleJobCount = (id, time, callback, count) => {
|
||||
let lco = 0;
|
||||
let mask = MCSERVER.Schedule.container[id] = schedule.scheduleJob(time, (fireDate) => {
|
||||
@ -29,4 +27,12 @@ module.exports.createScheduleJobCount = (id, time, callback, count) => {
|
||||
mask.cancel();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//删除
|
||||
module.exports.deleteScheduleJob = (id) => {
|
||||
let mask = MCSERVER.Schedule.container[id] || null;
|
||||
if (mask) {
|
||||
mask.cancel();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user