feat: 完成P6-P8后端能力与P9路由重构(V1-V2,D1,D3,B1-B2,B4,I1-I4,P9A2-P9A3)
这个提交包含在:
@@ -0,0 +1,41 @@
|
||||
const cron = require("node-cron");
|
||||
|
||||
const { runIntegrationOutboxOnce } = require("./integrationOutboxJob");
|
||||
|
||||
function startIntegrationOutboxWorker(fastify) {
|
||||
let running = false;
|
||||
|
||||
const task = cron.schedule(fastify.config.integrationOutboxCron, async () => {
|
||||
if (running) {
|
||||
return;
|
||||
}
|
||||
|
||||
running = true;
|
||||
try {
|
||||
await runIntegrationOutboxOnce(fastify.prisma, fastify.config, fastify.log);
|
||||
} catch (error) {
|
||||
fastify.log.error({ err: error }, "Integration outbox worker tick failed");
|
||||
} finally {
|
||||
running = false;
|
||||
}
|
||||
});
|
||||
|
||||
fastify.addHook("onClose", async () => {
|
||||
task.stop();
|
||||
task.destroy();
|
||||
});
|
||||
|
||||
fastify.log.info(
|
||||
{
|
||||
cron: fastify.config.integrationOutboxCron,
|
||||
batchSize: fastify.config.integrationOutboxBatchSize,
|
||||
},
|
||||
"Integration outbox worker scheduled",
|
||||
);
|
||||
|
||||
return task;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
startIntegrationOutboxWorker,
|
||||
};
|
||||
在新工单中引用
屏蔽一个用户