Add backend log management

This commit is contained in:
inman
2026-06-03 11:49:45 +08:00
parent 13ddc66cfe
commit fb0229ba06
14 changed files with 804 additions and 2 deletions

View File

@@ -7,6 +7,7 @@ import {
} from "@/lib/server/data-store";
import { advanceImageJob } from "@/lib/server/generation-service";
import { advanceVideoJob } from "@/lib/server/video-generation-service";
import { recordAppLog } from "@/lib/server/log-manager";
import { requestOrigin } from "@/lib/server/runtime";
import { deliverJobWebhook } from "@/lib/server/webhook";
import type { GenerationJob, GenerationStatus } from "@/lib/types";
@@ -53,6 +54,19 @@ export async function runWorkerTick(input: {
action: settled.action
});
} catch (error) {
await recordAppLog({
level: "error",
source: "worker.job",
message: `任务处理失败:${job.id}`,
error,
details: {
jobId: job.id,
capability: job.capability,
provider: job.provider,
attempts: job.attempts,
workerId
}
}).catch(() => undefined);
const failed = await updateGenerationJob(job.id, {
status: "failed",
error: {