This commit is contained in:
2026-01-10 16:58:15 +08:00
commit 48e3033639
53 changed files with 41267 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
import { getRedisConnection } from '../src/index.ts';
import { Queue } from 'bullmq'
export async function clearAllJobs() {
const connection = getRedisConnection();
const queueNames = [
'image-download',
'image-generate',
'perfect-prompt',
'perfect-sentence-prompt'
];
for (const queueName of queueNames) {
const queue = new Queue(queueName, { connection });
await queue.drain();
await queue.clean(0, 1000, 'completed');
await queue.clean(0, 1000, 'failed');
console.log(`Cleared all jobs in queue: ${queueName}`);
await queue.close();
}
await connection.quit();
}
clearAllJobs().then(() => {
console.log('All jobs cleared.');
process.exit(0);
}).catch((error) => {
console.error('Error clearing jobs:', error);
process.exit(1);
});

View File

@@ -0,0 +1,28 @@
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);
});