refactor(server): cron repository (#13988)

This commit is contained in:
Jason Rasmussen
2024-11-07 12:15:54 -05:00
committed by GitHub
parent 2fe6607aea
commit dc2de47204
13 changed files with 142 additions and 81 deletions

View File

@@ -27,12 +27,12 @@ export class BackupService extends BaseService {
this.backupLock = await this.databaseRepository.tryLock(DatabaseLock.BackupDatabase);
if (this.backupLock) {
this.jobRepository.addCronJob(
'backupDatabase',
database.cronExpression,
() => handlePromiseError(this.jobRepository.queue({ name: JobName.BACKUP_DATABASE }), this.logger),
database.enabled,
);
this.cronRepository.create({
name: 'backupDatabase',
expression: database.cronExpression,
onTick: () => handlePromiseError(this.jobRepository.queue({ name: JobName.BACKUP_DATABASE }), this.logger),
start: database.enabled,
});
}
}
@@ -42,7 +42,11 @@ export class BackupService extends BaseService {
return;
}
this.jobRepository.updateCronJob('backupDatabase', backup.database.cronExpression, backup.database.enabled);
this.cronRepository.update({
name: 'backupDatabase',
expression: backup.database.cronExpression,
start: backup.database.enabled,
});
}
@OnEvent({ name: 'config.validate' })