feat: Worker 进程拆分(F20)
- 新增 worker 进程入口(npm run worker)只跑作业不监听端口 - trialrun compose 增加 worker profile(server 可 JOBS_ENABLED=false) - 更新 runbook/.env.example/README 说明与 v3 CSV 状态推进
这个提交包含在:
@@ -2,6 +2,13 @@ const { buildApp } = require("./app");
|
||||
|
||||
async function main() {
|
||||
const app = await buildApp();
|
||||
app.log.info(
|
||||
{
|
||||
jobDriver: app.config.jobDriver,
|
||||
jobsEnabled: app.config.jobsEnabled,
|
||||
},
|
||||
"API process started",
|
||||
);
|
||||
|
||||
const { host, port } = app.config;
|
||||
await app.listen({ host, port });
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
const { buildApp } = require("./app");
|
||||
|
||||
async function main() {
|
||||
const app = await buildApp();
|
||||
app.log.info(
|
||||
{
|
||||
jobDriver: app.config.jobDriver,
|
||||
jobsEnabled: app.config.jobsEnabled,
|
||||
},
|
||||
"Worker process started",
|
||||
);
|
||||
|
||||
let shuttingDown = false;
|
||||
const shutdown = async (signal) => {
|
||||
if (shuttingDown) return;
|
||||
shuttingDown = true;
|
||||
|
||||
app.log.info({ signal }, "Worker graceful shutdown start");
|
||||
|
||||
const timeoutMs = 10_000;
|
||||
const forceTimer = setTimeout(() => {
|
||||
app.log.error({ timeoutMs }, "Worker graceful shutdown timeout, force exit");
|
||||
process.exit(1);
|
||||
}, timeoutMs);
|
||||
forceTimer.unref?.();
|
||||
|
||||
try {
|
||||
await app.close();
|
||||
app.log.info("Worker graceful shutdown completed");
|
||||
process.exit(0);
|
||||
} catch (error) {
|
||||
app.log.error({ err: error }, "Worker graceful shutdown failed");
|
||||
process.exit(1);
|
||||
}
|
||||
};
|
||||
|
||||
process.on("SIGTERM", () => shutdown("SIGTERM"));
|
||||
process.on("SIGINT", () => shutdown("SIGINT"));
|
||||
}
|
||||
|
||||
main().catch((err) => {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
在新工单中引用
屏蔽一个用户