feat(queue): auto clean up complete and fail jobs
This commit is contained in:
@@ -4,6 +4,7 @@ import logger from '../helpers/logger';
|
||||
import Step from '../models/step';
|
||||
import actionQueue from '../queues/action';
|
||||
import { processAction } from '../services/action';
|
||||
import { REMOVE_AFTER_30_DAYS_OR_150_JOBS, REMOVE_AFTER_7_DAYS_OR_50_JOBS } from '../helpers/remove-job-configuration';
|
||||
|
||||
type JobData = {
|
||||
flowId: string;
|
||||
@@ -31,7 +32,12 @@ export const worker = new Worker(
|
||||
stepId: nextStep.id,
|
||||
};
|
||||
|
||||
await actionQueue.add(jobName, jobPayload);
|
||||
const jobOptions = {
|
||||
removeOnComplete: REMOVE_AFTER_7_DAYS_OR_50_JOBS,
|
||||
removeOnFail: REMOVE_AFTER_30_DAYS_OR_150_JOBS,
|
||||
}
|
||||
|
||||
await actionQueue.add(jobName, jobPayload, jobOptions);
|
||||
},
|
||||
{ connection: redisConfig }
|
||||
);
|
||||
@@ -42,7 +48,7 @@ worker.on('completed', (job) => {
|
||||
|
||||
worker.on('failed', (job, err) => {
|
||||
logger.info(
|
||||
`JOB ID: ${job.id} - FLOW ID: ${job.data.flowId} has failed22 to start with ${err.message}`
|
||||
`JOB ID: ${job.id} - FLOW ID: ${job.data.flowId} has failed to start with ${err.message}`
|
||||
);
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user