28 lines
927 B
TypeScript
28 lines
927 B
TypeScript
import { IMAGE_DOWNLOAD_JOB } from '../src/task/image-creator.job'
|
|
import { Worker, Queue, Job } from 'bullmq';
|
|
import { getRedisConnection } from '../src/module/redis.ts';
|
|
import { pbService, jimengService, ossService } from '../src/index.ts';
|
|
|
|
const connection = getRedisConnection();
|
|
const queue = new Queue(IMAGE_DOWNLOAD_JOB, { connection });
|
|
|
|
// 显示错误的尝试任务, queue列出来
|
|
async function showFailedJobs() {
|
|
const failedJobs = await queue.getFailed();
|
|
if (failedJobs.length === 0) {
|
|
console.log('No failed jobs found.');
|
|
return;
|
|
}
|
|
|
|
console.log(`Found ${failedJobs.length} failed jobs:`);
|
|
for (const job of failedJobs) {
|
|
console.log(`- Job ID: ${job.id}, Attempts Made: ${job.attemptsMade}, Data: ${JSON.stringify(job.data)}`);
|
|
}
|
|
}
|
|
|
|
showFailedJobs().then(() => {
|
|
process.exit(0);
|
|
}).catch((error) => {
|
|
console.error('Error showing failed jobs:', error);
|
|
process.exit(1);
|
|
}); |