INNER CODE UNIT · TypeScript
cleanRepeatJobs
jonwiggins/optio · apps/api/src/index.ts:81
async function cleanRepeatJobs(queueName: string) {
const queue = new Queue(queueName, { connection: redisConnection });
try {
const repeatableJobs = await queue.getRepeatableJobs();
for (const job of repeatableJobs) {
await queue.removeRepeatableByKey(job.key);
}
if (repeatableJobs.length > 0) {
logger.info(
{ queue: queueName, removed: repeatableJobs.length },
"Cleaned stale repeat jobs",
);
}
} finally {
await queue.close();
}
}