mirror of
https://github.com/docmost/docmost.git
synced 2025-11-26 16:43:40 +10:00
fix processor
This commit is contained in:
@@ -47,15 +47,23 @@ export class FileTaskProcessor extends WorkerHost implements OnModuleDestroy {
|
|||||||
await this.handleFailedJob(job);
|
await this.handleFailedJob(job);
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnWorkerEvent('stalled')
|
@OnWorkerEvent('completed')
|
||||||
async onStalled(job: Job) {
|
async onCompleted(job: Job) {
|
||||||
this.logger.error(
|
this.logger.log(
|
||||||
`Job ${job.name} stalled. . Import Task ID: ${job.data.fileTaskId}.. Job ID: ${job.id}`,
|
`Completed ${job.name} job for File task ID ${job.data.fileTaskId}`,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Set failedReason for stalled jobs since it's not automatically set
|
try {
|
||||||
job.failedReason = 'Job stalled and was marked as failed';
|
const fileTask = await this.fileTaskService.getFileTask(
|
||||||
await this.handleFailedJob(job);
|
job.data.fileTaskId,
|
||||||
|
);
|
||||||
|
if (fileTask) {
|
||||||
|
await this.storageService.delete(fileTask.filePath);
|
||||||
|
this.logger.debug(`Deleted imported zip file: ${fileTask.filePath}`);
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
this.logger.error(`Failed to delete imported zip file:`, err);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async handleFailedJob(job: Job) {
|
private async handleFailedJob(job: Job) {
|
||||||
@@ -78,25 +86,6 @@ export class FileTaskProcessor extends WorkerHost implements OnModuleDestroy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnWorkerEvent('completed')
|
|
||||||
async onCompleted(job: Job) {
|
|
||||||
this.logger.log(
|
|
||||||
`Completed ${job.name} job for File task ID ${job.data.fileTaskId}`,
|
|
||||||
);
|
|
||||||
|
|
||||||
try {
|
|
||||||
const fileTask = await this.fileTaskService.getFileTask(
|
|
||||||
job.data.fileTaskId,
|
|
||||||
);
|
|
||||||
if (fileTask) {
|
|
||||||
await this.storageService.delete(fileTask.filePath);
|
|
||||||
this.logger.debug(`Deleted imported zip file: ${fileTask.filePath}`);
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
this.logger.error(`Failed to delete imported zip file:`, err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async onModuleDestroy(): Promise<void> {
|
async onModuleDestroy(): Promise<void> {
|
||||||
if (this.worker) {
|
if (this.worker) {
|
||||||
await this.worker.close();
|
await this.worker.close();
|
||||||
|
|||||||
Reference in New Issue
Block a user