@maiyunnet/kebab 9.3.14 → 9.4.0
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/doc/kebab-rag.md +1 -1
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/lib/undici/response.d.ts +1 -1
- package/package.json +1 -1
- package/sys/child.js +15 -4
package/doc/kebab-rag.md
CHANGED
|
@@ -1360,7 +1360,7 @@ index/variables/VER.md
|
|
|
1360
1360
|
|
|
1361
1361
|
# Variable: VER
|
|
1362
1362
|
|
|
1363
|
-
> `const` **VER**: `"9.
|
|
1363
|
+
> `const` **VER**: `"9.4.0"` = `'9.4.0'`
|
|
1364
1364
|
|
|
1365
1365
|
Defined in: [index.ts:10](https://github.com/maiyunnet/kebab/blob/master/index.ts#L10)
|
|
1366
1366
|
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* --- 本文件用来定义每个目录实体地址的常量 ---
|
|
7
7
|
*/
|
|
8
8
|
/** --- 当前系统版本号 --- */
|
|
9
|
-
export const VER = '9.
|
|
9
|
+
export const VER = '9.4.0';
|
|
10
10
|
// --- 服务端用的路径 ---
|
|
11
11
|
const imu = decodeURIComponent(import.meta.url).replace('file://', '').replace(/^\/(\w:)/, '$1');
|
|
12
12
|
/** --- /xxx/xxx --- */
|
package/lib/undici/response.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ export declare class Response {
|
|
|
31
31
|
/**
|
|
32
32
|
* --- 获取响应读取流对象 ---
|
|
33
33
|
*/
|
|
34
|
-
getStream(): (import("undici/types/readable").default & undici.Dispatcher.BodyMixin) |
|
|
34
|
+
getStream(): zlib.BrotliDecompress | zlib.Gunzip | zlib.Inflate | (import("undici/types/readable").default & undici.Dispatcher.BodyMixin) | null;
|
|
35
35
|
/**
|
|
36
36
|
* --- 获取原生响应读取流对象 ---
|
|
37
37
|
*/
|
package/package.json
CHANGED
package/sys/child.js
CHANGED
|
@@ -45,6 +45,8 @@ let httpServer;
|
|
|
45
45
|
let http2Server;
|
|
46
46
|
/** --- 当前使用中的连接 --- */
|
|
47
47
|
const linkCount = {};
|
|
48
|
+
/** --- 是否正在停止,停止时对 HTTP/1.1 响应追加 Connection: close,避免请求完成后连接回到保活池 --- */
|
|
49
|
+
let stopping = false;
|
|
48
50
|
/**
|
|
49
51
|
* --- 包装请求处理函数,统一管理 linkCount 计数和错误处理 ---
|
|
50
52
|
* @param key 连接标识
|
|
@@ -205,6 +207,10 @@ async function requestHandler(req, res, https) {
|
|
|
205
207
|
res.setHeader('Server', 'Kebab/' + kebab.VER);
|
|
206
208
|
res.setHeader('expires', 'Mon, 26 Jul 1994 05:00:00 GMT');
|
|
207
209
|
res.setHeader('cache-control', 'no-store');
|
|
210
|
+
// --- 停止中:通知 HTTP/1.1 客户端不要复用此连接(HTTP/2 由 GOAWAY 帧处理) ---
|
|
211
|
+
if (stopping && res instanceof http.ServerResponse) {
|
|
212
|
+
res.setHeader('connection', 'close');
|
|
213
|
+
}
|
|
208
214
|
// --- 当前 uri ---
|
|
209
215
|
let host = req.headers[':authority'];
|
|
210
216
|
if (host === undefined || typeof host !== 'string') {
|
|
@@ -551,26 +557,31 @@ process.on('message', function (msg) {
|
|
|
551
557
|
}
|
|
552
558
|
case 'stop': {
|
|
553
559
|
// --- 需要停止监听,等待已有连接全部断开,然后关闭线程 ---
|
|
560
|
+
stopping = true;
|
|
554
561
|
httpServer.close();
|
|
555
562
|
http2Server.close();
|
|
563
|
+
// --- 立即关闭空闲保活连接(无活跃请求的 keep-alive socket),避免进程长时间等待 ---
|
|
564
|
+
httpServer.closeIdleConnections();
|
|
556
565
|
clearInterval(hbTimer);
|
|
557
566
|
sMonitor.stop();
|
|
558
|
-
// ---
|
|
567
|
+
// --- 等待活跃请求全部完成 ---
|
|
559
568
|
/** --- 当前已等待时间,等待不超过 1 小时 --- */
|
|
560
569
|
let waiting = 0;
|
|
561
570
|
while (true) {
|
|
562
571
|
if (!Object.keys(linkCount).length) {
|
|
563
572
|
break;
|
|
564
573
|
}
|
|
565
|
-
// ---
|
|
574
|
+
// --- 有活跃连接,等待中 ---
|
|
566
575
|
const str = [];
|
|
567
576
|
for (const key in linkCount) {
|
|
568
577
|
str.push(key + ':' + linkCount[key].toString());
|
|
569
578
|
}
|
|
570
579
|
lCore.debug(`[CHILD] Worker ${process.pid} busy: ${str.join(',')}.`);
|
|
571
580
|
lCore.log({}, `[CHILD] Worker ${process.pid} busy: ${str.join(',')}.`, '-warning');
|
|
572
|
-
await lCore.sleep(
|
|
573
|
-
waiting +=
|
|
581
|
+
await lCore.sleep(5_000);
|
|
582
|
+
waiting += 5_000;
|
|
583
|
+
// --- 再次清理已变为空闲的保活连接 ---
|
|
584
|
+
httpServer.closeIdleConnections();
|
|
574
585
|
if (waiting > 3600_000) {
|
|
575
586
|
break;
|
|
576
587
|
}
|