@clairejs/server 3.28.2 → 3.28.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -84,18 +84,18 @@ export class AbstractJobScheduler {
|
|
|
84
84
|
update.lastError = String(err);
|
|
85
85
|
//-- job run error, check retry
|
|
86
86
|
const maxRetry = job.maxRetry || 0;
|
|
87
|
+
let retry = false;
|
|
87
88
|
if (maxRetry) {
|
|
88
89
|
const currentRetryCount = job.retryCount || 0;
|
|
89
|
-
|
|
90
|
+
retry = currentRetryCount < maxRetry;
|
|
91
|
+
if (retry) {
|
|
90
92
|
await this.retryJob(job, Date.now() + Math.max(job.retryDelayMs || 0, 60000));
|
|
91
93
|
update.retryCount = currentRetryCount + 1;
|
|
92
94
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
}
|
|
95
|
+
}
|
|
96
|
+
if (!retry && job.at) {
|
|
97
|
+
update.disabled = true;
|
|
98
|
+
await this.cancelJob(job.id);
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
await this.jobRepo.updateJobById(job.id, update, tx);
|
|
@@ -73,7 +73,7 @@ let AwsJobScheduler = class AwsJobScheduler extends AbstractJobScheduler {
|
|
|
73
73
|
async retryJob(job, at) {
|
|
74
74
|
const { id, disabled, execCount, failCount, retryCount, lastError, lastRunAt, lastSuccessAt, ...payload } = job;
|
|
75
75
|
const jobName = this.getJobUniqueName(id);
|
|
76
|
-
if (at) {
|
|
76
|
+
if (job.at) {
|
|
77
77
|
//-- update the job
|
|
78
78
|
const getCommand = new GetScheduleCommand({
|
|
79
79
|
Name: jobName,
|
|
@@ -88,7 +88,7 @@ let AwsJobScheduler = class AwsJobScheduler extends AbstractJobScheduler {
|
|
|
88
88
|
}
|
|
89
89
|
else {
|
|
90
90
|
//-- schedule a new one-time job to re-execute this cron with minus one maxRetry
|
|
91
|
-
await this.scheduleJob({ ...payload, at, maxRetry: (payload.maxRetry || 0) - 1 });
|
|
91
|
+
await this.scheduleJob({ ...payload, cron: undefined, at, maxRetry: (payload.maxRetry || 0) - 1 });
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
async cleanupJob(jobId) {
|
|
@@ -154,7 +154,7 @@ let LocalJobScheduler = class LocalJobScheduler extends AbstractJobScheduler {
|
|
|
154
154
|
}
|
|
155
155
|
else {
|
|
156
156
|
//-- schedule a new one-time job to re-execute this cron with minus one maxRetry
|
|
157
|
-
await this.scheduleJob({ ...payload, at, maxRetry: (job.maxRetry || 0) - 1 });
|
|
157
|
+
await this.scheduleJob({ ...payload, cron: undefined, at, maxRetry: (job.maxRetry || 0) - 1 });
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
160
|
async cleanupJob(jobId) {
|