统一 Node 22 与后端安全运行基线(07-15-production-trust-closeout-cleanup)
这个提交包含在:
+20
-5
@@ -1,7 +1,7 @@
|
||||
require("dotenv/config");
|
||||
|
||||
const { getConfig } = require("./config");
|
||||
const { initTracing } = require("./observability/tracing");
|
||||
const { initTracing, shutdownTracing } = require("./observability/tracing");
|
||||
|
||||
const config = getConfig();
|
||||
initTracing(config);
|
||||
@@ -35,22 +35,37 @@ async function main() {
|
||||
}, timeoutMs);
|
||||
forceTimer.unref?.();
|
||||
|
||||
let exitCode = 0;
|
||||
try {
|
||||
await app.close();
|
||||
app.log.info("Graceful shutdown completed");
|
||||
process.exit(0);
|
||||
} catch (error) {
|
||||
app.log.error({ err: error }, "Graceful shutdown failed");
|
||||
process.exit(1);
|
||||
exitCode = 1;
|
||||
}
|
||||
|
||||
try {
|
||||
await shutdownTracing();
|
||||
} catch (error) {
|
||||
app.log.error({ err: error }, "OTel shutdown failed");
|
||||
exitCode = 1;
|
||||
}
|
||||
|
||||
clearTimeout(forceTimer);
|
||||
app.log.info({ exitCode }, "Graceful shutdown completed");
|
||||
process.exit(exitCode);
|
||||
};
|
||||
|
||||
process.on("SIGTERM", () => shutdown("SIGTERM"));
|
||||
process.on("SIGINT", () => shutdown("SIGINT"));
|
||||
}
|
||||
|
||||
main().catch((err) => {
|
||||
main().catch(async (err) => {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(err);
|
||||
try {
|
||||
await shutdownTracing();
|
||||
} catch {
|
||||
// The startup error remains authoritative; shutdown is best effort here.
|
||||
}
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
在新工单中引用
屏蔽一个用户