typespeed 2.6.2 → 2.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/dist/default/express-server.class.js +39 -2
- package/dist/typespeed.d.ts +4 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,8 @@ typespeed 版本演进记录。本文件 2026-09-06 从 git 历史反推建立
|
|
|
4
4
|
|
|
5
5
|
## 2.6.x
|
|
6
6
|
|
|
7
|
+
- **2.6.4**:官方部署清单——多阶段 `Dockerfile`(build/run 分离 + 非 root + HEALTHCHECK);`docker-compose.yml`(app + MySQL/Redis/RabbitMQ,depends_on + healthcheck);k8s 清单(Deployment 带 readinessProbe→`/ready`、livenessProbe→`/health` + Service + Ingress);Helm chart(Chart/values/templates)(2026-09-07)
|
|
8
|
+
- **2.6.3**:框架内建优雅停机——`ExpressServer` 存储 `httpServer` + 新增 `stop()`(Promise 化 graceful close);SIGTERM/SIGINT 优雅停机(close 后 exit 0,30s 兜底强制退出),停机时关闭 Redis;socket 模式一并处理(2026-09-07)
|
|
7
9
|
- **2.6.2**:框架内建健康检查——新增 `HealthFactory`(abstract `ready()`)+ `HealthDefault`(默认恒就绪);`ExpressServer` 内建 `GET /health`(liveness)与 `GET /ready`(readiness,读 HealthFactory,200/503),路径可经 config 覆盖(2026-09-07)
|
|
8
10
|
- **2.6.1**:Node/TS 升级——TypeScript 4.9 → 5.9.3(legacy 装饰器零改动兼容,标准装饰器双轨同步验证);`@types/node` 对齐 22;声明 `engines`(node >=18)(2026-09-07)
|
|
9
11
|
|
|
@@ -26,6 +26,10 @@ const health_factory_class_1 = require("../factory/health-factory.class");
|
|
|
26
26
|
const redis_class_1 = require("./redis.class");
|
|
27
27
|
const authentication_factory_class_1 = require("../factory/authentication-factory.class");
|
|
28
28
|
class ExpressServer extends server_factory_class_1.default {
|
|
29
|
+
constructor() {
|
|
30
|
+
super(...arguments);
|
|
31
|
+
this.httpServer = null;
|
|
32
|
+
}
|
|
29
33
|
getSever() {
|
|
30
34
|
const server = new ExpressServer();
|
|
31
35
|
server.app = express();
|
|
@@ -39,13 +43,46 @@ class ExpressServer extends server_factory_class_1.default {
|
|
|
39
43
|
this.app.use(middleware);
|
|
40
44
|
});
|
|
41
45
|
this.setDefaultMiddleware();
|
|
46
|
+
let server;
|
|
42
47
|
if (this.socketIoConfig) {
|
|
43
48
|
const newSocketApp = socket_io_class_1.SocketIo.setIoServer(this.app, this.socketIoConfig);
|
|
44
|
-
|
|
49
|
+
server = newSocketApp.listen(port);
|
|
45
50
|
}
|
|
46
51
|
else {
|
|
47
|
-
|
|
52
|
+
server = this.app.listen(port);
|
|
48
53
|
}
|
|
54
|
+
this.httpServer = server;
|
|
55
|
+
this.registerGracefulShutdown();
|
|
56
|
+
return server;
|
|
57
|
+
}
|
|
58
|
+
stop() {
|
|
59
|
+
return new Promise((resolve) => {
|
|
60
|
+
if (this.httpServer) {
|
|
61
|
+
this.httpServer.close(() => resolve());
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
resolve();
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
registerGracefulShutdown() {
|
|
69
|
+
const shutdown = (signal) => {
|
|
70
|
+
(0, core_decorator_1.log)(`received ${signal}, gracefully shutting down...`);
|
|
71
|
+
// 30 秒兜底强制退出,防止连接迟迟不关闭
|
|
72
|
+
const forceExit = setTimeout(() => {
|
|
73
|
+
(0, core_decorator_1.log)("forced shutdown after timeout");
|
|
74
|
+
process.exit(1);
|
|
75
|
+
}, 30000);
|
|
76
|
+
forceExit.unref();
|
|
77
|
+
redis_class_1.Redis.close().catch(() => { });
|
|
78
|
+
this.httpServer.close(() => {
|
|
79
|
+
clearTimeout(forceExit);
|
|
80
|
+
(0, core_decorator_1.log)("server closed");
|
|
81
|
+
process.exit(0);
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
process.on("SIGTERM", () => shutdown("SIGTERM"));
|
|
85
|
+
process.on("SIGINT", () => shutdown("SIGINT"));
|
|
49
86
|
}
|
|
50
87
|
setDefaultMiddleware() {
|
|
51
88
|
this.app.use(express.urlencoded({ extended: true }));
|
package/dist/typespeed.d.ts
CHANGED
|
@@ -388,6 +388,10 @@ declare class ExpressServer extends ServerFactory {
|
|
|
388
388
|
getSever(): ServerFactory;
|
|
389
389
|
setMiddleware(middleware: any): void;
|
|
390
390
|
start(port: number): void;
|
|
391
|
+
/**HTTP 服务实例(start 后可用) */
|
|
392
|
+
httpServer: any;
|
|
393
|
+
/**优雅停机:关闭 HTTP 服务(排空在途连接) */
|
|
394
|
+
stop(): Promise<void>;
|
|
391
395
|
private setDefaultMiddleware;
|
|
392
396
|
}
|
|
393
397
|
/**Socket IO 装饰器类 */
|