23 lines
903 B
JavaScript
23 lines
903 B
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
const logger = require("./log");
|
|
const MqttDispatcher_1 = require("./MqttDispatcher");
|
|
const cron = require("cron");
|
|
class Cron {
|
|
constructor(name, target, crontab) {
|
|
this.name = name;
|
|
this.targetTopic = target.getInTopic();
|
|
this.crontab = crontab;
|
|
}
|
|
start() {
|
|
this.crontab.forEach((cronEntry) => {
|
|
logger.info(`Starting cronjob for: ${this.targetTopic}, ${cronEntry.output} at ${cronEntry.cronTime}`);
|
|
cronEntry.cronJob = new cron.CronJob(cronEntry.cronTime, () => {
|
|
logger.info(`Firing ${this.targetTopic}, ${cronEntry.output}`);
|
|
MqttDispatcher_1.mqttHandler.send(this.targetTopic, cronEntry.output);
|
|
}, undefined, true, 'Europe/Berlin');
|
|
});
|
|
}
|
|
}
|
|
exports.Cron = Cron;
|
|
//# sourceMappingURL=Cron.js.map
|