initialize
This commit is contained in:
commit
99b6232436
24 changed files with 3872 additions and 0 deletions
37
cron-jobs.js
Normal file
37
cron-jobs.js
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
const config = require("./config");
|
||||
|
||||
const cron = require("node-cron");
|
||||
const { Log } = require("./lib/common");
|
||||
|
||||
// CRON JOB GUIDE
|
||||
// # ┌────────────── วินาที (optional)
|
||||
// # │ ┌──────────── นาที
|
||||
// # │ │ ┌────────── ชั่วโมง
|
||||
// # │ │ │ ┌──────── วันที่
|
||||
// # │ │ │ │ ┌────── เดือน
|
||||
// # │ │ │ │ │ ┌──── วันในสัปดาห์นั้น ๆ
|
||||
// # │ │ │ │ │ │
|
||||
// # │ │ │ │ │ │
|
||||
// # * * * * * *
|
||||
|
||||
const CronScheduleList = {
|
||||
everyMin: "* * * * *",
|
||||
midNight: "0 0 * * *",
|
||||
};
|
||||
|
||||
const CronJobs = {
|
||||
MAXIMUM_CRON_JOBS: -1,
|
||||
getAllRunning: cron.getTasks(),
|
||||
doEveryMinute: (task, id) => {
|
||||
if(config.DEBUG) Log.debug(`verify cron ${cron.validate(CronScheduleList.everyMin)}`);
|
||||
return cron.schedule(CronScheduleList.everyMin, task, { name: id });
|
||||
},
|
||||
doEveryMidnight: (task, id) => {
|
||||
if(config.DEBUG) Log.debug(`verify cron ${cron.validate(CronScheduleList.midNight)}`);
|
||||
return cron.schedule(CronScheduleList.midNight, task, { name: id });
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
CronJobs,
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue