mirror of
https://github.com/cool-team-official/cool-admin-midway.git
synced 2026-03-19 04:03:50 +00:00
完善定时任务
This commit is contained in:
parent
28f624420a
commit
b07faab723
@ -8,7 +8,7 @@
|
||||
"@cool-midway/core": "^4.0.15",
|
||||
"@cool-midway/es": "^4.0.2",
|
||||
"@cool-midway/oss": "^4.0.3",
|
||||
"@cool-midway/queue": "^4.1.0",
|
||||
"@cool-midway/queue": "^4.1.2",
|
||||
"@cool-midway/redis": "^4.0.5",
|
||||
"@cool-midway/socket": "^4.0.2",
|
||||
"@cool-midway/wxpay": "^4.0.3",
|
||||
|
||||
@ -21,10 +21,12 @@ export abstract class TaskInfoQueue extends BaseCoolQueue {
|
||||
const result = await this.taskInfoService.invokeService(job.data.service);
|
||||
this.taskInfoService.record(job.data, 1, JSON.stringify(result));
|
||||
} catch (error) {
|
||||
this.taskInfoService.record(job.data, 0, error);
|
||||
this.taskInfoService.record(job.data, 0, error.message);
|
||||
}
|
||||
if (!job.data.isOnce) {
|
||||
this.taskInfoService.updateNextRunTime(job.data.id);
|
||||
this.taskInfoService.updateStatus(job.data.id);
|
||||
}
|
||||
this.taskInfoService.updateNextRunTime(job.data.id);
|
||||
this.taskInfoService.updateStatus(job.data.id);
|
||||
done();
|
||||
}
|
||||
}
|
||||
|
||||
@ -71,11 +71,17 @@ export class TaskInfoService extends BaseService {
|
||||
async once(id) {
|
||||
const task = await this.taskInfoEntity.findOne({ id });
|
||||
if (task) {
|
||||
await this.taskInfoQueue.add(task, {
|
||||
jobId: task.id.toString(),
|
||||
removeOnComplete: true,
|
||||
removeOnFail: true,
|
||||
});
|
||||
await this.taskInfoQueue.add(
|
||||
{
|
||||
...task,
|
||||
isOnce: true,
|
||||
},
|
||||
{
|
||||
jobId: task.id.toString(),
|
||||
removeOnComplete: true,
|
||||
removeOnFail: true,
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user