Updated the startTimer function to use cron in the timer task

This commit is contained in:
Mathias Wagner
2022-08-29 12:44:08 +02:00
parent 434d00f7b6
commit 0c2ea28a96

View File

@@ -1,10 +1,12 @@
const pauseController = require('../controller/pause');
const schedule = require('node-schedule');
const {isValidCron} = require("cron-validator");
let job;
module.exports.startTimer = (timeLevel) => {
job = schedule.scheduleJob(getRuleFromLevel(timeLevel), () => this.runTask());
module.exports.startTimer = (cron) => {
if (!isValidCron(cron)) return;
job = schedule.scheduleJob(cron, () => this.runTask());
}
module.exports.runTask = async () => {