Files
dispatcher_ng/dist/Cron.js
Wolfgang Hottgenroth 9c0ac6dc3b Cron implemented
2018-01-15 17:49:25 +01:00

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