feat(server): 试运行部署与运营基线(E13/E14/E17/E19/E20/E21)
- 增加 deploy/trialrun:Docker Compose + env 模板 + runbook + 发布/回滚 checklist - 新增 DB/文件存储备份恢复脚本(backup/restore) - 新增 system.users 运营接口:创建/启用禁用/重置密码/分配角色 + 审计 - 新增 seed:trialrun 引导管理员账号(一次性口令) - 补齐 SIGTERM/SIGINT 优雅停机(关闭 job/HTTP/DB)
这个提交包含在:
+27
-1
@@ -5,6 +5,33 @@ async function main() {
|
||||
|
||||
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) => {
|
||||
@@ -12,4 +39,3 @@ main().catch((err) => {
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
|
||||
在新工单中引用
屏蔽一个用户