fix(core): update

This commit is contained in:
2019-04-10 14:06:20 +02:00
parent 6d8e39f11b
commit f9b81fc801
4 changed files with 113 additions and 53 deletions

View File

@ -1,3 +1,35 @@
import * as plugins from './smarttime.plugins';
export class CronManager {}
export class CronManager {
public status: 'started' | 'stopped' = 'stopped';
public cronjobs: plugins.cron.CronJob[] = [];
public addCronjob(cronIdentifierArg: string, cronFunctionArg: plugins.cron.CronCommand) {
const newCronJob = new plugins.cron.CronJob(cronIdentifierArg,cronFunctionArg);
if (this.status === 'started') {
newCronJob.start();
}
this.cronjobs.push(newCronJob);
};
/**
* starts the cronjob
*/
public start() {
this.status = 'started';
for (const cron of this.cronjobs) {
cron.start();
}
}
/**
* stops all cronjobs
*/
public stop() {
this.status = 'stopped';
for (const cron of this.cronjobs) {
cron.stop();
}
}
}