fix(core): update

This commit is contained in:
2020-09-03 20:06:02 +00:00
parent f129ce42b6
commit 8e43ce7e9b
3 changed files with 42 additions and 19 deletions

View File

@@ -21,11 +21,14 @@ export class CronJob {
*/
public checkExecution(): number {
if (this.nextExecutionUnix === 0) {
this.nextExecutionUnix = this.croner.msToNext();
this.nextExecutionUnix = Date.now() + this.croner.msToNext();
}
if (Date.now() > this.nextExecutionUnix) {
this.jobFunction();
this.nextExecutionUnix = this.croner.msToNext();
const maybePromise = this.jobFunction();
if (maybePromise instanceof Promise) {
maybePromise.catch(e => console.log(e));
}
this.nextExecutionUnix = Date.now() + this.croner.msToNext();
}
return this.nextExecutionUnix;
}