fix(core): update
This commit is contained in:
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user