Perform deferred jobs on shutdown (#729)

This commit is contained in:
KOBA789 2024-09-16 20:56:21 +09:00 committed by GitHub
parent 5138672232
commit 98cba06848
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 50 additions and 20 deletions

View file

@ -1101,17 +1101,18 @@ export class NoteCreateService implements OnApplicationShutdown {
}
@bindThis
private performUpdateNotesCount(id: MiNote['id'], incrBy: number) {
this.instancesRepository.increment({ id: id }, 'notesCount', incrBy);
private async performUpdateNotesCount(id: MiNote['id'], incrBy: number) {
await this.instancesRepository.increment({ id: id }, 'notesCount', incrBy);
}
@bindThis
public dispose(): void {
public async dispose(): Promise<void> {
this.#shutdownController.abort();
await this.updateNotesCountQueue.performAllNow();
}
@bindThis
public onApplicationShutdown(signal?: string | undefined): void {
this.dispose();
public async onApplicationShutdown(signal?: string | undefined): Promise<void> {
await this.dispose();
}
}