- 增加 deploy/trialrun:Docker Compose + env 模板 + runbook + 发布/回滚 checklist - 新增 DB/文件存储备份恢复脚本(backup/restore) - 新增 system.users 运营接口:创建/启用禁用/重置密码/分配角色 + 审计 - 新增 seed:trialrun 引导管理员账号(一次性口令) - 补齐 SIGTERM/SIGINT 优雅停机(关闭 job/HTTP/DB)
42 行
1016 B
JavaScript
42 行
1016 B
JavaScript
const { buildApp } = require("./app");
|
|
|
|
async function main() {
|
|
const app = await buildApp();
|
|
|
|
const { host, port } = app.config;
|
|
await app.listen({ host, port });
|
|
|
|
let shuttingDown = false;
|
|
const shutdown = async (signal) => {
|
|
if (shuttingDown) return;
|
|
shuttingDown = true;
|
|
|
|
app.log.info({ signal }, "Graceful shutdown start");
|
|
|
|
const timeoutMs = 10_000;
|
|
const forceTimer = setTimeout(() => {
|
|
app.log.error({ timeoutMs }, "Graceful shutdown timeout, force exit");
|
|
process.exit(1);
|
|
}, timeoutMs);
|
|
forceTimer.unref?.();
|
|
|
|
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);
|
|
}
|
|
};
|
|
|
|
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);
|
|
});
|