46 lines
2.8 KiB
JavaScript
46 lines
2.8 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.CronManager = void 0;
|
|
const smarttime_classes_cronjob_1 = require("./smarttime.classes.cronjob");
|
|
const smarttime_classes_interval_1 = require("./smarttime.classes.interval");
|
|
class CronManager {
|
|
constructor() {
|
|
this.cronInterval = new smarttime_classes_interval_1.Interval(1000);
|
|
this.status = 'stopped';
|
|
this.cronjobs = [];
|
|
this.cronInterval.addIntervalJob(() => {
|
|
for (const cronJob of this.cronjobs) {
|
|
cronJob.checkExecution();
|
|
}
|
|
});
|
|
}
|
|
addCronjob(cronIdentifierArg, cronFunctionArg) {
|
|
const newCronJob = new smarttime_classes_cronjob_1.CronJob(this, cronIdentifierArg, cronFunctionArg);
|
|
this.cronjobs.push(newCronJob);
|
|
if (this.status === 'started') {
|
|
newCronJob.start();
|
|
}
|
|
}
|
|
/**
|
|
* starts the cronjob
|
|
*/
|
|
start() {
|
|
this.status = 'started';
|
|
for (const cron of this.cronjobs) {
|
|
cron.start();
|
|
}
|
|
this.cronInterval.start();
|
|
}
|
|
/**
|
|
* stops all cronjobs
|
|
*/
|
|
stop() {
|
|
this.status = 'stopped';
|
|
for (const cron of this.cronjobs) {
|
|
cron.stop();
|
|
}
|
|
this.cronInterval.stop();
|
|
}
|
|
}
|
|
exports.CronManager = CronManager;
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnR0aW1lLmNsYXNzZXMuY3Jvbm1hbmFnZXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydHRpbWUuY2xhc3Nlcy5jcm9ubWFuYWdlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFDQSwyRUFBc0Q7QUFFdEQsNkVBQXdEO0FBRXhELE1BQWEsV0FBVztJQU10QjtRQUxPLGlCQUFZLEdBQUcsSUFBSSxxQ0FBUS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