更新下载图像方法以返回 Uint8Array,调整下载任务的重试延迟和并发设置,优化提示词工作者的日志输出
This commit is contained in:
@@ -80,7 +80,7 @@ export class JimengService {
|
||||
}
|
||||
}
|
||||
|
||||
async downloadImage(url: string): Promise<Buffer> {
|
||||
async downloadImage(url: string): Promise<Uint8Array> {
|
||||
const controller = new AbortController();
|
||||
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
||||
|
||||
@@ -96,7 +96,7 @@ export class JimengService {
|
||||
}
|
||||
|
||||
const arrayBuffer = await response.arrayBuffer();
|
||||
return Buffer.from(arrayBuffer);
|
||||
return new Uint8Array(arrayBuffer);
|
||||
} catch (error: any) {
|
||||
clearTimeout(timeoutId);
|
||||
if (error.name === 'AbortError') {
|
||||
|
||||
@@ -95,7 +95,7 @@ export async function addImageDownloadJob(
|
||||
attempts: DOWNLOAD_MAX_RETRIES,
|
||||
backoff: {
|
||||
type: 'exponential',
|
||||
delay: 2000, // 初始 2 秒
|
||||
delay: 200, // 初始 200 毫秒
|
||||
},
|
||||
removeOnComplete: 100,
|
||||
removeOnFail: 100,
|
||||
@@ -147,7 +147,7 @@ export async function runImageDownloadWorker(): Promise<void> {
|
||||
},
|
||||
{
|
||||
connection,
|
||||
concurrency: 3,
|
||||
concurrency: 1, // 避免更新冲突
|
||||
lockDuration: 60000 * 5, // 锁持续时间 5分钟
|
||||
stalledInterval: 30000, // 每30秒检查一次 stalled
|
||||
} as any
|
||||
@@ -162,7 +162,7 @@ export async function runImageDownloadWorker(): Promise<void> {
|
||||
notify.notify(`[ImageDownload] \nJob failed: ${job?.id}, error: ${err.message}\n Job data: ${JSON.stringify(job?.data)}`);
|
||||
});
|
||||
|
||||
console.log('[ImageDownload] Worker started');
|
||||
console.log('[ImageDownload] Worker 开始运行');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -226,7 +226,7 @@ export async function runImageGenerateWorker(): Promise<void> {
|
||||
}
|
||||
});
|
||||
|
||||
console.log('[ImageGenerate] Worker started');
|
||||
console.log('[ImageGenerate] Worker 开始运行');
|
||||
}
|
||||
|
||||
export { updateItemStatus };
|
||||
|
||||
@@ -116,6 +116,6 @@ export const runPerfectSentencePromptWorker = () => {
|
||||
notify.notify(`[Sentence] 提示词优化工作者在条目 ${job.data.itemId} 达到最大重试次数后停止`);
|
||||
}
|
||||
});
|
||||
|
||||
console.log('[Sentence] Worker 开始运行');
|
||||
return worker;
|
||||
};
|
||||
Reference in New Issue
Block a user