fix(core): update

This commit is contained in:
2020-05-25 21:45:43 +00:00
parent c968e156ae
commit dd722146f4
29 changed files with 19349 additions and 824 deletions

View File

@@ -1,16 +1,28 @@
import * as plugins from './smarttime.plugins';
import { CronJob } from './smarttime.classes.cronjob';
import { Timer } from './smarttime.classes.timer';
import { Interval } from './smarttime.classes.interval';
export class CronManager {
public cronInterval = new Interval(1000);
public status: 'started' | 'stopped' = 'stopped';
public cronjobs: CronJob[] = [];
public cronjobs: plugins.cron.CronJob[] = [];
constructor() {
this.cronInterval.addIntervalJob(() => {
for (const cronJob of this.cronjobs) {
cronJob.checkExecution();
}
});
}
public addCronjob(cronIdentifierArg: string, cronFunctionArg: plugins.cron.CronCommand) {
const newCronJob = new plugins.cron.CronJob(cronIdentifierArg, cronFunctionArg);
public addCronjob(cronIdentifierArg: string, cronFunctionArg: () => any) {
const newCronJob = new CronJob(this, cronIdentifierArg, cronFunctionArg);
this.cronjobs.push(newCronJob);
if (this.status === 'started') {
newCronJob.start();
}
this.cronjobs.push(newCronJob);
}
/**
@@ -21,6 +33,7 @@ export class CronManager {
for (const cron of this.cronjobs) {
cron.start();
}
this.cronInterval.start();
}
/**
@@ -31,5 +44,6 @@ export class CronManager {
for (const cron of this.cronjobs) {
cron.stop();
}
this.cronInterval.stop();
}
}