@maiyunnet/kebab 9.22.2 → 9.22.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/doc/kebab-rag.md CHANGED
@@ -1717,7 +1717,7 @@ index/variables/VER.md
1717
1717
 
1718
1718
  # Variable: VER
1719
1719
 
1720
- > `const` **VER**: `"9.22.2"` = `'9.22.2'`
1720
+ > `const` **VER**: `"9.22.4"` = `'9.22.4'`
1721
1721
 
1722
1722
  Defined in: [index.ts:10](https://github.com/maiyunnet/kebab/blob/master/index.ts#L10)
1723
1723
 
@@ -3707,7 +3707,7 @@ lib/core/functions/clone.md
3707
3707
 
3708
3708
  > **clone**\<`T`\>(`obj`): `T`
3709
3709
 
3710
- Defined in: [lib/core.ts:1541](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1541)
3710
+ Defined in: [lib/core.ts:1468](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1468)
3711
3711
 
3712
3712
  完整的克隆一份数组/对象
3713
3713
 
@@ -3771,7 +3771,7 @@ lib/core/functions/debug.md
3771
3771
 
3772
3772
  > **debug**(`message?`, ...`optionalParams`): `void`
3773
3773
 
3774
- Defined in: [lib/core.ts:1587](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1587)
3774
+ Defined in: [lib/core.ts:1514](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1514)
3775
3775
 
3776
3776
  打印调试信息,线上环境不会打印
3777
3777
 
@@ -3806,7 +3806,7 @@ lib/core/functions/display.md
3806
3806
 
3807
3807
  > **display**(`message?`, ...`optionalParams`): `void`
3808
3808
 
3809
- Defined in: [lib/core.ts:1600](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1600)
3809
+ Defined in: [lib/core.ts:1527](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1527)
3810
3810
 
3811
3811
  向控制台直接显示内容,一般情况下禁止使用
3812
3812
 
@@ -3918,7 +3918,7 @@ lib/core/functions/getLog.md
3918
3918
 
3919
3919
  > **getLog**(`opt`): `Promise`\<`false` \| \{ `list`: `any`[] \| `string`[][]; `total`: `number`; \}\>
3920
3920
 
3921
- Defined in: [lib/core.ts:1321](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1321)
3921
+ Defined in: [lib/core.ts:1248](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1248)
3922
3922
 
3923
3923
  获取日志内容为一个数组
3924
3924
 
@@ -3987,7 +3987,7 @@ lib/core/functions/getMonitorEvent.md
3987
3987
 
3988
3988
  > **getMonitorEvent**(`opt`): `Promise`\<`false` \| [`IMonitorEvent`](../interfaces/IMonitorEvent.md) \| `null`\>
3989
3989
 
3990
- Defined in: [lib/core.ts:1457](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1457)
3990
+ Defined in: [lib/core.ts:1384](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1384)
3991
3991
 
3992
3992
  读取事件详情和文件清单;只解析事件记录,不解析 Profile 或堆快照
3993
3993
 
@@ -4024,7 +4024,7 @@ lib/core/functions/getMonitorEvents.md
4024
4024
 
4025
4025
  > **getMonitorEvents**(`opt?`): `Promise`\<`false` \| \{ `list`: [`IMonitorEventSummary`](../interfaces/IMonitorEventSummary.md)[]; `total`: `number`; \}\>
4026
4026
 
4027
- Defined in: [lib/core.ts:1430](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1430)
4027
+ Defined in: [lib/core.ts:1357](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1357)
4028
4028
 
4029
4029
  获取某天已保存的监控事件,按目录时间倒序分页
4030
4030
 
@@ -4071,7 +4071,7 @@ lib/core/functions/getMonitorFile.md
4071
4071
 
4072
4072
  > **getMonitorFile**(`opt`): `Promise`\<`false` \| [`Response`](../../undici/response/classes/Response.md) \| `null`\>
4073
4073
 
4074
- Defined in: [lib/core.ts:1481](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1481)
4074
+ Defined in: [lib/core.ts:1408](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1408)
4075
4075
 
4076
4076
  获取监控原始文件的响应,可使用 getStream() 下载;小文件可用 getText()/getJson() 预览
4077
4077
 
@@ -4216,7 +4216,7 @@ lib/core/functions/loadEnv.md
4216
4216
 
4217
4217
  > **loadEnv**(`dir`): `Promise`\<`void`\>
4218
4218
 
4219
- Defined in: [lib/core.ts:1671](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1671)
4219
+ Defined in: [lib/core.ts:1598](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1598)
4220
4220
 
4221
4221
  加载 .env 文件到 process.env,若文件不存在则跳过
4222
4222
 
@@ -4245,7 +4245,7 @@ lib/core/functions/log.md
4245
4245
 
4246
4246
  > **log**(`opt`, `msg`, `fend?`): `void`
4247
4247
 
4248
- Defined in: [lib/core.ts:1208](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1208)
4248
+ Defined in: [lib/core.ts:1135](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1135)
4249
4249
 
4250
4250
  写入文件日志
4251
4251
 
@@ -4286,7 +4286,7 @@ lib/core/functions/ls.md
4286
4286
 
4287
4287
  > **ls**(`opt`): `Promise`\<`object`[]\>
4288
4288
 
4289
- Defined in: [lib/core.ts:1502](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1502)
4289
+ Defined in: [lib/core.ts:1429](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1429)
4290
4290
 
4291
4291
  获取目录内文件/文件夹列表
4292
4292
 
@@ -4656,7 +4656,7 @@ lib/core/functions/removeGlobal.md
4656
4656
 
4657
4657
  > **removeGlobal**(`key`, `hosts?`): `Promise`\<`Record`\<`string`, \{ `result`: `boolean`; `return`: `string`; \}\>\>
4658
4658
 
4659
- Defined in: [lib/core.ts:1025](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1025)
4659
+ Defined in: [lib/core.ts:977](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L977)
4660
4660
 
4661
4661
  移除某个跨线程/跨内网服务器全局变量
4662
4662
 
@@ -4691,7 +4691,7 @@ lib/core/functions/resolveEnvVars.md
4691
4691
 
4692
4692
  > **resolveEnvVars**(`obj`): `void`
4693
4693
 
4694
- Defined in: [lib/core.ts:1701](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1701)
4694
+ Defined in: [lib/core.ts:1628](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1628)
4695
4695
 
4696
4696
  将配置对象中的 ${ENV_VAR} 占位符替换为 process.env 的值
4697
4697
 
@@ -4720,7 +4720,7 @@ lib/core/functions/sendNpm.md
4720
4720
 
4721
4721
  > **sendNpm**(`path`, `hosts?`): `Promise`\<`Record`\<`string`, \{ `result`: `boolean`; `return`: `string`; \}\>\>
4722
4722
 
4723
- Defined in: [lib/core.ts:924](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L924)
4723
+ Defined in: [lib/core.ts:890](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L890)
4724
4724
 
4725
4725
  向本机或局域网 RPC 发送 npm install 操作
4726
4726
 
@@ -4755,7 +4755,7 @@ lib/core/functions/sendPackage.md
4755
4755
 
4756
4756
  > **sendPackage**(`content`, `hosts?`): `Promise`\<`Record`\<`string`, \{ `result`: `boolean`; `return`: `string`; \}\>\>
4757
4757
 
4758
- Defined in: [lib/core.ts:1148](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1148)
4758
+ Defined in: [lib/core.ts:1082](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1082)
4759
4759
 
4760
4760
  向本机或局域网 RPC 发送 package.json 更新操作
4761
4761
 
@@ -4790,7 +4790,7 @@ lib/core/functions/sendPm2.md
4790
4790
 
4791
4791
  > **sendPm2**(`name`, `action?`, `hosts?`): `Promise`\<`Record`\<`string`, \{ `result`: `boolean`; `return`: `string`; \}\>\>
4792
4792
 
4793
- Defined in: [lib/core.ts:876](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L876)
4793
+ Defined in: [lib/core.ts:849](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L849)
4794
4794
 
4795
4795
  向本机或局域网 RPC 发送 PM2 操作
4796
4796
 
@@ -4833,7 +4833,7 @@ lib/core/functions/sendProject.md
4833
4833
 
4834
4834
  > **sendProject**(`path`, `key`, `value`, `hosts?`): `Promise`\<`Record`\<`string`, \{ `result`: `boolean`; `return`: `string`; \}\>\>
4835
4835
 
4836
- Defined in: [lib/core.ts:1100](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1100)
4836
+ Defined in: [lib/core.ts:1041](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1041)
4837
4837
 
4838
4838
  向本机或局域网 RPC 发送项目配置更新操作
4839
4839
 
@@ -4908,7 +4908,7 @@ lib/core/functions/sendRestart.md
4908
4908
 
4909
4909
  > **sendRestart**(`hosts?`): `Promise`\<`Record`\<`string`, \{ `result`: `boolean`; `return`: `string`; \}\>\>
4910
4910
 
4911
- Defined in: [lib/core.ts:763](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L763)
4911
+ Defined in: [lib/core.ts:754](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L754)
4912
4912
 
4913
4913
  向主进程(或局域网同代码机子)发送广播将进行 restart 操作,停止监听并启动新进程,老进程在连接全部断开后自行销毁
4914
4914
  主要用作不间断的代码热更新
@@ -4936,7 +4936,7 @@ lib/core/functions/sendStop.md
4936
4936
 
4937
4937
  > **sendStop**(`hosts?`): `Promise`\<`Record`\<`string`, \{ `result`: `boolean`; `return`: `string`; \}\>\>
4938
4938
 
4939
- Defined in: [lib/core.ts:817](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L817)
4939
+ Defined in: [lib/core.ts:799](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L799)
4940
4940
 
4941
4941
  向主进程(或局域网同代码机子)发送 stop 操作,停止接收新连接并在现有连接全部结束后退出
4942
4942
 
@@ -5014,7 +5014,7 @@ lib/core/functions/setGlobal.md
5014
5014
 
5015
5015
  > **setGlobal**(`key`, `data`, `hosts?`): `Promise`\<`Record`\<`string`, \{ `result`: `boolean`; `return`: `string`; \}\>\>
5016
5016
 
5017
- Defined in: [lib/core.ts:975](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L975)
5017
+ Defined in: [lib/core.ts:934](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L934)
5018
5018
 
5019
5019
  设置跨线程/指定的局域网主机的全局变量
5020
5020
 
@@ -5113,7 +5113,7 @@ lib/core/functions/updateCode.md
5113
5113
 
5114
5114
  > **updateCode**(`sourcePath`, `path`, `hosts?`, `config?`, `strict?`): `Promise`\<`Record`\<`string`, \{ `result`: `boolean`; `return`: `string`; \}\>\>
5115
5115
 
5116
- Defined in: [lib/core.ts:1040](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1040)
5116
+ Defined in: [lib/core.ts:992](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L992)
5117
5117
 
5118
5118
  上传并覆盖代码文件,config.json、kebab.json、.js.map、.ts, .gitignore 不会被覆盖和新创建
5119
5119
 
@@ -5166,7 +5166,7 @@ lib/core/functions/writeEventStreamHead.md
5166
5166
 
5167
5167
  > **writeEventStreamHead**(`res`): `void`
5168
5168
 
5169
- Defined in: [lib/core.ts:1641](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1641)
5169
+ Defined in: [lib/core.ts:1568](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1568)
5170
5170
 
5171
5171
  提交服务器发送事件(SSE)响应头
5172
5172
 
@@ -5201,7 +5201,7 @@ lib/core/functions/writeHead.md
5201
5201
 
5202
5202
  > **writeHead**(`res`, `statusCode`, `headers?`): `void`
5203
5203
 
5204
- Defined in: [lib/core.ts:1620](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1620)
5204
+ Defined in: [lib/core.ts:1547](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1547)
5205
5205
 
5206
5206
  提交 HTTP 响应状态和头部,兼容 HTTP/1.1 与 HTTP/2
5207
5207
 
@@ -5251,7 +5251,7 @@ lib/core/functions/write.md
5251
5251
 
5252
5252
  > **write**(`res`, `data`): `void`
5253
5253
 
5254
- Defined in: [lib/core.ts:1653](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1653)
5254
+ Defined in: [lib/core.ts:1580](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1580)
5255
5255
 
5256
5256
  向 res 发送数据
5257
5257
 
@@ -5437,7 +5437,7 @@ lib/core/interfaces/ILogOptions.md
5437
5437
 
5438
5438
  # Interface: ILogOptions
5439
5439
 
5440
- Defined in: [lib/core.ts:1191](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1191)
5440
+ Defined in: [lib/core.ts:1118](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1118)
5441
5441
 
5442
5442
  log 设置的选项
5443
5443
 
@@ -5447,7 +5447,7 @@ log 设置的选项
5447
5447
 
5448
5448
  > `optional` **cookie?**: `Record`\<`string`, `string`\>
5449
5449
 
5450
- Defined in: [lib/core.ts:1197](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1197)
5450
+ Defined in: [lib/core.ts:1124](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1124)
5451
5451
 
5452
5452
  ***
5453
5453
 
@@ -5455,7 +5455,7 @@ Defined in: [lib/core.ts:1197](https://github.com/maiyunnet/kebab/blob/master/li
5455
5455
 
5456
5456
  > `optional` **get?**: `Record`\<`string`, `any`\>
5457
5457
 
5458
- Defined in: [lib/core.ts:1196](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1196)
5458
+ Defined in: [lib/core.ts:1123](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1123)
5459
5459
 
5460
5460
  ***
5461
5461
 
@@ -5463,7 +5463,7 @@ Defined in: [lib/core.ts:1196](https://github.com/maiyunnet/kebab/blob/master/li
5463
5463
 
5464
5464
  > `optional` **headers?**: `IncomingHttpHeaders`
5465
5465
 
5466
- Defined in: [lib/core.ts:1199](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1199)
5466
+ Defined in: [lib/core.ts:1126](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1126)
5467
5467
 
5468
5468
  ***
5469
5469
 
@@ -5471,7 +5471,7 @@ Defined in: [lib/core.ts:1199](https://github.com/maiyunnet/kebab/blob/master/li
5471
5471
 
5472
5472
  > `optional` **hostname?**: `string`
5473
5473
 
5474
- Defined in: [lib/core.ts:1194](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1194)
5474
+ Defined in: [lib/core.ts:1121](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1121)
5475
5475
 
5476
5476
  ***
5477
5477
 
@@ -5479,7 +5479,7 @@ Defined in: [lib/core.ts:1194](https://github.com/maiyunnet/kebab/blob/master/li
5479
5479
 
5480
5480
  > `optional` **path?**: `string`
5481
5481
 
5482
- Defined in: [lib/core.ts:1192](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1192)
5482
+ Defined in: [lib/core.ts:1119](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1119)
5483
5483
 
5484
5484
  ***
5485
5485
 
@@ -5487,7 +5487,7 @@ Defined in: [lib/core.ts:1192](https://github.com/maiyunnet/kebab/blob/master/li
5487
5487
 
5488
5488
  > `optional` **req?**: `IncomingMessage` \| `Http2ServerRequest` \| `null`
5489
5489
 
5490
- Defined in: [lib/core.ts:1195](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1195)
5490
+ Defined in: [lib/core.ts:1122](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1122)
5491
5491
 
5492
5492
  ***
5493
5493
 
@@ -5495,7 +5495,7 @@ Defined in: [lib/core.ts:1195](https://github.com/maiyunnet/kebab/blob/master/li
5495
5495
 
5496
5496
  > `optional` **session?**: `Record`\<`string`, `any`\>
5497
5497
 
5498
- Defined in: [lib/core.ts:1198](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1198)
5498
+ Defined in: [lib/core.ts:1125](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1125)
5499
5499
 
5500
5500
  ***
5501
5501
 
@@ -5503,7 +5503,7 @@ Defined in: [lib/core.ts:1198](https://github.com/maiyunnet/kebab/blob/master/li
5503
5503
 
5504
5504
  > `optional` **urlFull?**: `string`
5505
5505
 
5506
- Defined in: [lib/core.ts:1193](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1193)
5506
+ Defined in: [lib/core.ts:1120](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1120)
5507
5507
 
5508
5508
  lib/core/interfaces/IMonitorEvent.md
5509
5509
  ---
@@ -5516,7 +5516,7 @@ lib/core/interfaces/IMonitorEvent.md
5516
5516
 
5517
5517
  # Interface: IMonitorEvent
5518
5518
 
5519
- Defined in: [lib/core.ts:1387](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1387)
5519
+ Defined in: [lib/core.ts:1314](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1314)
5520
5520
 
5521
5521
  事件原始数据与可读取的文件;data 为 null 时可下载原始记录复盘
5522
5522
 
@@ -5526,7 +5526,7 @@ Defined in: [lib/core.ts:1387](https://github.com/maiyunnet/kebab/blob/master/li
5526
5526
 
5527
5527
  > **data**: `Record`\<`string`, `unknown`\> \| `null`
5528
5528
 
5529
- Defined in: [lib/core.ts:1389](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1389)
5529
+ Defined in: [lib/core.ts:1316](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1316)
5530
5530
 
5531
5531
  ***
5532
5532
 
@@ -5534,7 +5534,7 @@ Defined in: [lib/core.ts:1389](https://github.com/maiyunnet/kebab/blob/master/li
5534
5534
 
5535
5535
  > **files**: [`IMonitorFile`](IMonitorFile.md)[]
5536
5536
 
5537
- Defined in: [lib/core.ts:1391](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1391)
5537
+ Defined in: [lib/core.ts:1318](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1318)
5538
5538
 
5539
5539
  ***
5540
5540
 
@@ -5542,7 +5542,7 @@ Defined in: [lib/core.ts:1391](https://github.com/maiyunnet/kebab/blob/master/li
5542
5542
 
5543
5543
  > **recordStatus**: `"loaded"` \| `"invalid"` \| `"missing"` \| `"too-large"` \| `"unreadable"`
5544
5544
 
5545
- Defined in: [lib/core.ts:1390](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1390)
5545
+ Defined in: [lib/core.ts:1317](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1317)
5546
5546
 
5547
5547
  ***
5548
5548
 
@@ -5550,7 +5550,7 @@ Defined in: [lib/core.ts:1390](https://github.com/maiyunnet/kebab/blob/master/li
5550
5550
 
5551
5551
  > **summary**: [`IMonitorEventSummary`](IMonitorEventSummary.md)
5552
5552
 
5553
- Defined in: [lib/core.ts:1388](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1388)
5553
+ Defined in: [lib/core.ts:1315](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1315)
5554
5554
 
5555
5555
  lib/core/interfaces/IMonitorEventSummary.md
5556
5556
  ---
@@ -5563,7 +5563,7 @@ lib/core/interfaces/IMonitorEventSummary.md
5563
5563
 
5564
5564
  # Interface: IMonitorEventSummary
5565
5565
 
5566
- Defined in: [lib/core.ts:1367](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1367)
5566
+ Defined in: [lib/core.ts:1294](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1294)
5567
5567
 
5568
5568
  已保存监控事件的简短摘要,path 相对于 log/monitor/
5569
5569
 
@@ -5573,7 +5573,7 @@ Defined in: [lib/core.ts:1367](https://github.com/maiyunnet/kebab/blob/master/li
5573
5573
 
5574
5574
  > **path**: `string`
5575
5575
 
5576
- Defined in: [lib/core.ts:1368](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1368)
5576
+ Defined in: [lib/core.ts:1295](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1295)
5577
5577
 
5578
5578
  ***
5579
5579
 
@@ -5581,7 +5581,7 @@ Defined in: [lib/core.ts:1368](https://github.com/maiyunnet/kebab/blob/master/li
5581
5581
 
5582
5582
  > **pid**: `number`
5583
5583
 
5584
- Defined in: [lib/core.ts:1369](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1369)
5584
+ Defined in: [lib/core.ts:1296](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1296)
5585
5585
 
5586
5586
  ***
5587
5587
 
@@ -5589,7 +5589,7 @@ Defined in: [lib/core.ts:1369](https://github.com/maiyunnet/kebab/blob/master/li
5589
5589
 
5590
5590
  > **reasons**: `string`[]
5591
5591
 
5592
- Defined in: [lib/core.ts:1373](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1373)
5592
+ Defined in: [lib/core.ts:1300](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1300)
5593
5593
 
5594
5594
  ***
5595
5595
 
@@ -5597,7 +5597,7 @@ Defined in: [lib/core.ts:1373](https://github.com/maiyunnet/kebab/blob/master/li
5597
5597
 
5598
5598
  > **source**: `"main"` \| `"watchdog"`
5599
5599
 
5600
- Defined in: [lib/core.ts:1371](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1371)
5600
+ Defined in: [lib/core.ts:1298](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1298)
5601
5601
 
5602
5602
  ***
5603
5603
 
@@ -5605,7 +5605,7 @@ Defined in: [lib/core.ts:1371](https://github.com/maiyunnet/kebab/blob/master/li
5605
5605
 
5606
5606
  > **status**: `string`
5607
5607
 
5608
- Defined in: [lib/core.ts:1372](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1372)
5608
+ Defined in: [lib/core.ts:1299](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1299)
5609
5609
 
5610
5610
  ***
5611
5611
 
@@ -5613,7 +5613,7 @@ Defined in: [lib/core.ts:1372](https://github.com/maiyunnet/kebab/blob/master/li
5613
5613
 
5614
5614
  > **time**: `number`
5615
5615
 
5616
- Defined in: [lib/core.ts:1370](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1370)
5616
+ Defined in: [lib/core.ts:1297](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1297)
5617
5617
 
5618
5618
  lib/core/interfaces/IMonitorFile.md
5619
5619
  ---
@@ -5626,7 +5626,7 @@ lib/core/interfaces/IMonitorFile.md
5626
5626
 
5627
5627
  # Interface: IMonitorFile
5628
5628
 
5629
- Defined in: [lib/core.ts:1377](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1377)
5629
+ Defined in: [lib/core.ts:1304](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1304)
5630
5630
 
5631
5631
  监控文件元数据;复杂格式或超过 1 MiB 的文件不提供预览
5632
5632
 
@@ -5636,7 +5636,7 @@ Defined in: [lib/core.ts:1377](https://github.com/maiyunnet/kebab/blob/master/li
5636
5636
 
5637
5637
  > **mtime**: `number`
5638
5638
 
5639
- Defined in: [lib/core.ts:1382](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1382)
5639
+ Defined in: [lib/core.ts:1309](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1309)
5640
5640
 
5641
5641
  最后修改时间,单位 ms
5642
5642
 
@@ -5646,7 +5646,7 @@ Defined in: [lib/core.ts:1382](https://github.com/maiyunnet/kebab/blob/master/li
5646
5646
 
5647
5647
  > **name**: `string`
5648
5648
 
5649
- Defined in: [lib/core.ts:1379](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1379)
5649
+ Defined in: [lib/core.ts:1306](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1306)
5650
5650
 
5651
5651
  ***
5652
5652
 
@@ -5654,7 +5654,7 @@ Defined in: [lib/core.ts:1379](https://github.com/maiyunnet/kebab/blob/master/li
5654
5654
 
5655
5655
  > **path**: `string`
5656
5656
 
5657
- Defined in: [lib/core.ts:1378](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1378)
5657
+ Defined in: [lib/core.ts:1305](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1305)
5658
5658
 
5659
5659
  ***
5660
5660
 
@@ -5662,7 +5662,7 @@ Defined in: [lib/core.ts:1378](https://github.com/maiyunnet/kebab/blob/master/li
5662
5662
 
5663
5663
  > **preview**: `"text"` \| `"json"` \| `null`
5664
5664
 
5665
- Defined in: [lib/core.ts:1383](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1383)
5665
+ Defined in: [lib/core.ts:1310](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1310)
5666
5666
 
5667
5667
  ***
5668
5668
 
@@ -5670,7 +5670,7 @@ Defined in: [lib/core.ts:1383](https://github.com/maiyunnet/kebab/blob/master/li
5670
5670
 
5671
5671
  > **size**: `number`
5672
5672
 
5673
- Defined in: [lib/core.ts:1380](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1380)
5673
+ Defined in: [lib/core.ts:1307](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1307)
5674
5674
 
5675
5675
  lib/core/namespaces/v/classes/ValiError.md
5676
5676
  ---
@@ -114901,7 +114901,7 @@ lib/core/type-aliases/TPm2Action.md
114901
114901
 
114902
114902
  > **TPm2Action** = `"start"` \| `"stop"` \| `"restart"`
114903
114903
 
114904
- Defined in: [lib/core.ts:867](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L867)
114904
+ Defined in: [lib/core.ts:840](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L840)
114905
114905
 
114906
114906
  PM2 操作类型
114907
114907
 
@@ -114975,7 +114975,7 @@ lib/core/variables/global.md
114975
114975
 
114976
114976
  > `const` **global**: `Record`\<`string`, `any`\> = `{}`
114977
114977
 
114978
- Defined in: [lib/core.ts:967](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L967)
114978
+ Defined in: [lib/core.ts:926](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L926)
114979
114979
 
114980
114980
  跨进程全局变量
114981
114981
 
@@ -133898,19 +133898,9 @@ Defined in: [sys/ctr.ts:1256](https://github.com/maiyunnet/kebab/blob/master/sys
133898
133898
 
133899
133899
  ##### events?
133900
133900
 
133901
- 文件处理情况
133902
-
133903
- ###### onfiledata?
133904
-
133905
- (`chunk`) => `void`
133906
-
133907
- ###### onfileend?
133901
+ [`IFormDataEvents`](../../route/interfaces/IFormDataEvents.md) = `{}`
133908
133902
 
133909
- () => `void`
133910
-
133911
- ###### onfilestart?
133912
-
133913
- (`name`) => `boolean` \| `undefined`
133903
+ 文件处理情况
133914
133904
 
133915
133905
  ##### limits?
133916
133906
 
@@ -133922,7 +133912,7 @@ Defined in: [sys/ctr.ts:1256](https://github.com/maiyunnet/kebab/blob/master/sys
133922
133912
 
133923
133913
  `Promise`\<`boolean`\>
133924
133914
 
133925
- 是否解析成功;失败原因通过 limits.onError 通知,连接中断时可能无法发送响应
133915
+ 是否解析成功;失败原因通过 events.onerror 通知,连接中断时可能无法发送响应
133926
133916
 
133927
133917
  ***
133928
133918
 
@@ -138122,7 +138112,7 @@ sys/route/functions/getFormData.md
138122
138112
 
138123
138113
  > **getFormData**(`req`, `events?`, `limits?`): `Promise`\<`false` \| \{ `files`: `Record`\<`string`, [`IPostFile`](../../../index/interfaces/IPostFile.md) \| [`IPostFile`](../../../index/interfaces/IPostFile.md)[]\>; `post`: `Record`\<`string`, [`Json`](../../../index/type-aliases/Json.md)\>; \}\>
138124
138114
 
138125
- Defined in: [sys/route.ts:1069](https://github.com/maiyunnet/kebab/blob/master/sys/route.ts#L1069)
138115
+ Defined in: [sys/route.ts:1079](https://github.com/maiyunnet/kebab/blob/master/sys/route.ts#L1079)
138126
138116
 
138127
138117
  获取 formdata 的 post
138128
138118
 
@@ -138136,25 +138126,9 @@ Defined in: [sys/route.ts:1069](https://github.com/maiyunnet/kebab/blob/master/s
138136
138126
 
138137
138127
  ### events?
138138
138128
 
138139
- 文件处理情况
138140
-
138141
- #### onfiledata?
138142
-
138143
- (`chunk`) => `void`
138144
-
138145
- 文件上传时触发,仅 start 返回 true 时触发
138146
-
138147
- #### onfileend?
138148
-
138149
- () => `void`
138150
-
138151
- 文件上传结束时触发,仅 start 返回 true 时触发
138152
-
138153
- #### onfilestart?
138129
+ [`IFormDataEvents`](../interfaces/IFormDataEvents.md) = `{}`
138154
138130
 
138155
- (`name`) => `boolean` \| `undefined`
138156
-
138157
- 文件开始上传时触发,返回 true 则跳过该文件的保存
138131
+ 文件处理情况
138158
138132
 
138159
138133
  ### limits?
138160
138134
 
@@ -138166,7 +138140,7 @@ Defined in: [sys/route.ts:1069](https://github.com/maiyunnet/kebab/blob/master/s
138166
138140
 
138167
138141
  `Promise`\<`false` \| \{ `files`: `Record`\<`string`, [`IPostFile`](../../../index/interfaces/IPostFile.md) \| [`IPostFile`](../../../index/interfaces/IPostFile.md)[]\>; `post`: `Record`\<`string`, [`Json`](../../../index/type-aliases/Json.md)\>; \}\>
138168
138142
 
138169
- 字段和临时文件;失败返回 false,并通过 limits.onError 通知首次失败原因
138143
+ 字段和临时文件;失败返回 false,并通过 events.onerror 通知首次失败原因
138170
138144
 
138171
138145
  sys/route/functions/getPost.md
138172
138146
  ---
@@ -138359,6 +138333,7 @@ sys/route/index.md
138359
138333
  ## Interfaces
138360
138334
 
138361
138335
  - [IFormDataError](interfaces/IFormDataError.md)
138336
+ - [IFormDataEvents](interfaces/IFormDataEvents.md)
138362
138337
  - [IFormDataLimits](interfaces/IFormDataLimits.md)
138363
138338
 
138364
138339
  ## Functions
@@ -138403,6 +138378,95 @@ Defined in: [sys/route.ts:1039](https://github.com/maiyunnet/kebab/blob/master/s
138403
138378
 
138404
138379
  触发的限制值;大小按字节,超时按毫秒,段数按个
138405
138380
 
138381
+ sys/route/interfaces/IFormDataEvents.md
138382
+ ---
138383
+
138384
+ [**Documents for @maiyunnet/kebab**](../../../index.md)
138385
+
138386
+ ***
138387
+
138388
+ [Documents for @maiyunnet/kebab](../../../index.md) / [sys/route](../index.md) / IFormDataEvents
138389
+
138390
+ # Interface: IFormDataEvents
138391
+
138392
+ Defined in: [sys/route.ts:1043](https://github.com/maiyunnet/kebab/blob/master/sys/route.ts#L1043)
138393
+
138394
+ multipart 文件处理及失败通知
138395
+
138396
+ ## Properties
138397
+
138398
+ ### onerror?
138399
+
138400
+ > `optional` **onerror?**: (`error`) => `void`
138401
+
138402
+ Defined in: [sys/route.ts:1051](https://github.com/maiyunnet/kebab/blob/master/sys/route.ts#L1051)
138403
+
138404
+ 首次失败时通知一次;原有 false 返回值不变,连接中断时响应可能无法送达
138405
+
138406
+ #### Parameters
138407
+
138408
+ ##### error
138409
+
138410
+ [`IFormDataError`](IFormDataError.md)
138411
+
138412
+ #### Returns
138413
+
138414
+ `void`
138415
+
138416
+ ***
138417
+
138418
+ ### onfiledata?
138419
+
138420
+ > `optional` **onfiledata?**: (`chunk`) => `void`
138421
+
138422
+ Defined in: [sys/route.ts:1047](https://github.com/maiyunnet/kebab/blob/master/sys/route.ts#L1047)
138423
+
138424
+ 文件上传时触发,仅 start 返回 true 时触发
138425
+
138426
+ #### Parameters
138427
+
138428
+ ##### chunk
138429
+
138430
+ `Buffer`
138431
+
138432
+ #### Returns
138433
+
138434
+ `void`
138435
+
138436
+ ***
138437
+
138438
+ ### onfileend?
138439
+
138440
+ > `optional` **onfileend?**: () => `void`
138441
+
138442
+ Defined in: [sys/route.ts:1049](https://github.com/maiyunnet/kebab/blob/master/sys/route.ts#L1049)
138443
+
138444
+ 文件上传结束时触发,仅 start 返回 true 时触发
138445
+
138446
+ #### Returns
138447
+
138448
+ `void`
138449
+
138450
+ ***
138451
+
138452
+ ### onfilestart?
138453
+
138454
+ > `optional` **onfilestart?**: (`name`) => `boolean` \| `undefined`
138455
+
138456
+ Defined in: [sys/route.ts:1045](https://github.com/maiyunnet/kebab/blob/master/sys/route.ts#L1045)
138457
+
138458
+ 文件开始上传时触发,返回 true 则跳过该文件的保存
138459
+
138460
+ #### Parameters
138461
+
138462
+ ##### name
138463
+
138464
+ `string`
138465
+
138466
+ #### Returns
138467
+
138468
+ `boolean` \| `undefined`
138469
+
138406
138470
  sys/route/interfaces/IFormDataLimits.md
138407
138471
  ---
138408
138472
 
@@ -138414,9 +138478,9 @@ sys/route/interfaces/IFormDataLimits.md
138414
138478
 
138415
138479
  # Interface: IFormDataLimits
138416
138480
 
138417
- Defined in: [sys/route.ts:1043](https://github.com/maiyunnet/kebab/blob/master/sys/route.ts#L1043)
138481
+ Defined in: [sys/route.ts:1055](https://github.com/maiyunnet/kebab/blob/master/sys/route.ts#L1055)
138418
138482
 
138419
- multipart 上传限制及失败通知
138483
+ multipart 上传限制
138420
138484
 
138421
138485
  ## Properties
138422
138486
 
@@ -138424,7 +138488,7 @@ multipart 上传限制及失败通知
138424
138488
 
138425
138489
  > `optional` **allowedExts?**: `string`[]
138426
138490
 
138427
- Defined in: [sys/route.ts:1047](https://github.com/maiyunnet/kebab/blob/master/sys/route.ts#L1047)
138491
+ Defined in: [sys/route.ts:1059](https://github.com/maiyunnet/kebab/blob/master/sys/route.ts#L1059)
138428
138492
 
138429
138493
  允许的文件扩展名(含点号),如 ['.jpg', '.png', '.pdf']
138430
138494
 
@@ -138434,7 +138498,7 @@ Defined in: [sys/route.ts:1047](https://github.com/maiyunnet/kebab/blob/master/s
138434
138498
 
138435
138499
  > `optional` **maxFieldSize?**: `number`
138436
138500
 
138437
- Defined in: [sys/route.ts:1049](https://github.com/maiyunnet/kebab/blob/master/sys/route.ts#L1049)
138501
+ Defined in: [sys/route.ts:1061](https://github.com/maiyunnet/kebab/blob/master/sys/route.ts#L1061)
138438
138502
 
138439
138503
  单个字段(非文件)最大字节数,默认 1 MB
138440
138504
 
@@ -138444,7 +138508,7 @@ Defined in: [sys/route.ts:1049](https://github.com/maiyunnet/kebab/blob/master/s
138444
138508
 
138445
138509
  > `optional` **maxFileSize?**: `number`
138446
138510
 
138447
- Defined in: [sys/route.ts:1045](https://github.com/maiyunnet/kebab/blob/master/sys/route.ts#L1045)
138511
+ Defined in: [sys/route.ts:1057](https://github.com/maiyunnet/kebab/blob/master/sys/route.ts#L1057)
138448
138512
 
138449
138513
  单个文件最大字节数
138450
138514
 
@@ -138454,7 +138518,7 @@ Defined in: [sys/route.ts:1045](https://github.com/maiyunnet/kebab/blob/master/s
138454
138518
 
138455
138519
  > `optional` **maxHeaderSize?**: `number`
138456
138520
 
138457
- Defined in: [sys/route.ts:1053](https://github.com/maiyunnet/kebab/blob/master/sys/route.ts#L1053)
138521
+ Defined in: [sys/route.ts:1065](https://github.com/maiyunnet/kebab/blob/master/sys/route.ts#L1065)
138458
138522
 
138459
138523
  单个 multipart 段头部最大字节数,默认 16 KB
138460
138524
 
@@ -138464,7 +138528,7 @@ Defined in: [sys/route.ts:1053](https://github.com/maiyunnet/kebab/blob/master/s
138464
138528
 
138465
138529
  > `optional` **maxParts?**: `number`
138466
138530
 
138467
- Defined in: [sys/route.ts:1055](https://github.com/maiyunnet/kebab/blob/master/sys/route.ts#L1055)
138531
+ Defined in: [sys/route.ts:1067](https://github.com/maiyunnet/kebab/blob/master/sys/route.ts#L1067)
138468
138532
 
138469
138533
  multipart 字段与文件总数量,默认 1000
138470
138534
 
@@ -138474,36 +138538,16 @@ multipart 字段与文件总数量,默认 1000
138474
138538
 
138475
138539
  > `optional` **maxTotalSize?**: `number`
138476
138540
 
138477
- Defined in: [sys/route.ts:1051](https://github.com/maiyunnet/kebab/blob/master/sys/route.ts#L1051)
138541
+ Defined in: [sys/route.ts:1063](https://github.com/maiyunnet/kebab/blob/master/sys/route.ts#L1063)
138478
138542
 
138479
138543
  整体请求最大字节数,不设置或设为 0 则不限制
138480
138544
 
138481
138545
  ***
138482
138546
 
138483
- ### onError?
138484
-
138485
- > `optional` **onError?**: (`error`) => `void`
138486
-
138487
- Defined in: [sys/route.ts:1059](https://github.com/maiyunnet/kebab/blob/master/sys/route.ts#L1059)
138488
-
138489
- 首次失败时通知一次;原有 false 返回值不变,连接中断时响应可能无法送达
138490
-
138491
- #### Parameters
138492
-
138493
- ##### error
138494
-
138495
- [`IFormDataError`](IFormDataError.md)
138496
-
138497
- #### Returns
138498
-
138499
- `void`
138500
-
138501
- ***
138502
-
138503
138547
  ### timeout?
138504
138548
 
138505
138549
  > `optional` **timeout?**: `number`
138506
138550
 
138507
- Defined in: [sys/route.ts:1057](https://github.com/maiyunnet/kebab/blob/master/sys/route.ts#L1057)
138551
+ Defined in: [sys/route.ts:1069](https://github.com/maiyunnet/kebab/blob/master/sys/route.ts#L1069)
138508
138552
 
138509
138553
  整体请求超时时间(毫秒),默认 5 分钟,设为 0 禁用超时
package/index.d.ts CHANGED
@@ -5,7 +5,7 @@
5
5
  * --- 本文件用来定义每个目录实体地址的常量 ---
6
6
  */
7
7
  /** --- 当前系统版本号 --- */
8
- export declare const VER = "9.22.2";
8
+ export declare const VER = "9.22.4";
9
9
  /** --- 框架根目录,以 / 结尾 --- */
10
10
  export declare const ROOT_PATH: string;
11
11
  /** --- 框架的 LIB,以 / 结尾 --- */
package/index.js CHANGED
@@ -6,7 +6,7 @@
6
6
  * --- 本文件用来定义每个目录实体地址的常量 ---
7
7
  */
8
8
  /** --- 当前系统版本号 --- */
9
- export const VER = '9.22.2';
9
+ export const VER = '9.22.4';
10
10
  // --- 服务端用的路径 ---
11
11
  const imu = decodeURIComponent(import.meta.url).replace('file://', '').replace(/^\/(\w:)/, '$1');
12
12
  /** --- /xxx/xxx --- */
package/lib/core.js CHANGED
@@ -638,31 +638,22 @@ export async function sendReload(hosts) {
638
638
  if (!hosts?.length) {
639
639
  hosts = ['127.0.0.1'];
640
640
  }
641
- // --- 局域网模式 ---
642
- const time = lTime.stamp();
643
- /** --- 返回成功的 host --- */
644
- const rtn = {};
645
- for (const host of hosts) {
641
+ /** --- 并行发送,各主机独立等待,结果保持输入顺序 --- */
642
+ const results = await Promise.all(hosts.map(async (host) => {
646
643
  const res = await lUndici.get('http://' + host + ':' + globalConfig.rpcPort.toString() + '/' + lCrypto.aesEncrypt(lText.stringifyJson({
647
644
  'action': 'reload',
648
- 'time': time
645
+ 'time': lTime.stamp()
649
646
  }), globalConfig.rpcSecret), {
650
647
  'timeout': 5
651
648
  });
652
649
  const content = await res.getContent();
653
650
  if (!content) {
654
- rtn[host] = { 'result': false, 'return': 'Timeout' };
655
- continue;
651
+ return [host, { 'result': false, 'return': 'Timeout' }];
656
652
  }
657
653
  const str = content.toString();
658
- if (str === 'Done') {
659
- rtn[host] = { 'result': true, 'return': 'Done' };
660
- }
661
- else {
662
- rtn[host] = { 'result': false, 'return': str };
663
- }
664
- }
665
- return rtn;
654
+ return [host, { 'result': str === 'Done', 'return': str }];
655
+ }));
656
+ return Object.fromEntries(results);
666
657
  }
667
658
  /**
668
659
  * --- 向主进程(或局域网同代码机子)发送广播将进行 restart 操作,停止监听并启动新进程,老进程在连接全部断开后自行销毁 ---
@@ -687,31 +678,22 @@ export async function sendRestart(hosts) {
687
678
  if (!hosts?.length) {
688
679
  hosts = ['127.0.0.1'];
689
680
  }
690
- // --- 局域网模式 ---
691
- const time = lTime.stamp();
692
- /** --- 返回成功的 host --- */
693
- const rtn = {};
694
- for (const host of hosts) {
681
+ /** --- 并行发送,各主机独立等待,结果保持输入顺序 --- */
682
+ const results = await Promise.all(hosts.map(async (host) => {
695
683
  const res = await lUndici.get('http://' + host + ':' + globalConfig.rpcPort.toString() + '/' + lCrypto.aesEncrypt(lText.stringifyJson({
696
684
  'action': 'restart',
697
- 'time': time
685
+ 'time': lTime.stamp()
698
686
  }), globalConfig.rpcSecret), {
699
687
  'timeout': 5
700
688
  });
701
689
  const content = await res.getContent();
702
690
  if (!content) {
703
- rtn[host] = { 'result': false, 'return': 'Timeout' };
704
- continue;
691
+ return [host, { 'result': false, 'return': 'Timeout' }];
705
692
  }
706
693
  const str = content.toString();
707
- if (str === 'Done') {
708
- rtn[host] = { 'result': true, 'return': 'Done' };
709
- }
710
- else {
711
- rtn[host] = { 'result': false, 'return': str };
712
- }
713
- }
714
- return rtn;
694
+ return [host, { 'result': str === 'Done', 'return': str }];
695
+ }));
696
+ return Object.fromEntries(results);
715
697
  }
716
698
  /**
717
699
  * --- 向主进程(或局域网同代码机子)发送 stop 操作,停止接收新连接并在现有连接全部结束后退出 ---
@@ -737,31 +719,22 @@ export async function sendStop(hosts) {
737
719
  if (!hosts?.length) {
738
720
  hosts = ['127.0.0.1'];
739
721
  }
740
- // --- 局域网模式 ---
741
- const time = lTime.stamp();
742
- /** --- 返回成功的 host --- */
743
- const rtn = {};
744
- for (const host of hosts) {
722
+ /** --- 并行发送,各主机独立等待,结果保持输入顺序 --- */
723
+ const results = await Promise.all(hosts.map(async (host) => {
745
724
  const res = await lUndici.get('http://' + host + ':' + globalConfig.rpcPort.toString() + '/' + lCrypto.aesEncrypt(lText.stringifyJson({
746
725
  'action': 'stop',
747
- 'time': time
726
+ 'time': lTime.stamp()
748
727
  }), globalConfig.rpcSecret), {
749
728
  'timeout': 5
750
729
  });
751
730
  const content = await res.getContent();
752
731
  if (!content) {
753
- rtn[host] = { 'result': false, 'return': 'Timeout' };
754
- continue;
732
+ return [host, { 'result': false, 'return': 'Timeout' }];
755
733
  }
756
734
  const str = content.toString();
757
- if (str === 'Done') {
758
- rtn[host] = { 'result': true, 'return': 'Done' };
759
- }
760
- else {
761
- rtn[host] = { 'result': false, 'return': str };
762
- }
763
- }
764
- return rtn;
735
+ return [host, { 'result': str === 'Done', 'return': str }];
736
+ }));
737
+ return Object.fromEntries(results);
765
738
  }
766
739
  /**
767
740
  * --- 向本机或局域网 RPC 发送 PM2 操作 ---
@@ -778,14 +751,11 @@ export async function sendPm2(name, action = 'restart', hosts) {
778
751
  if (!hosts?.length) {
779
752
  hosts = ['127.0.0.1'];
780
753
  }
781
- // --- 局域网模式 ---
782
- const time = lTime.stamp();
783
- /** --- 返回成功的 host --- */
784
- const rtn = {};
785
- for (const host of hosts) {
754
+ /** --- 并行发送,各主机独立等待,结果保持输入顺序 --- */
755
+ const results = await Promise.all(hosts.map(async (host) => {
786
756
  const res = await lUndici.get('http://' + host + ':' + globalConfig.rpcPort.toString() + '/' + lCrypto.aesEncrypt(lText.stringifyJson({
787
757
  'action': 'pm2',
788
- 'time': time,
758
+ 'time': lTime.stamp(),
789
759
  'name': name,
790
760
  'pm2Action': action
791
761
  }), globalConfig.rpcSecret), {
@@ -793,19 +763,15 @@ export async function sendPm2(name, action = 'restart', hosts) {
793
763
  });
794
764
  const content = await res.getContent();
795
765
  if (!content) {
796
- rtn[host] = { 'result': false, 'return': 'Timeout' };
797
- continue;
766
+ return [host, { 'result': false, 'return': 'Timeout' }];
798
767
  }
799
768
  const str = content.toString();
800
- if (str === 'Done') {
801
- rtn[host] = { 'result': true, 'return': 'Done' };
802
- }
803
- else {
804
- rtn[host] = { 'result': false, 'return': str };
769
+ if (str !== 'Done') {
805
770
  debug('[CORE][sendPm2] rpc server content error:', str);
806
771
  }
807
- }
808
- return rtn;
772
+ return [host, { 'result': str === 'Done', 'return': str }];
773
+ }));
774
+ return Object.fromEntries(results);
809
775
  }
810
776
  /**
811
777
  * --- 向本机或局域网 RPC 发送 npm install 操作 ---
@@ -820,33 +786,26 @@ export async function sendNpm(path, hosts) {
820
786
  if (!hosts?.length) {
821
787
  hosts = ['127.0.0.1'];
822
788
  }
823
- // --- 局域网模式 ---
824
- const time = lTime.stamp();
825
- /** --- 返回成功的 host --- */
826
- const rtn = {};
827
- for (const host of hosts) {
789
+ /** --- 并行发送,各主机独立等待,结果保持输入顺序 --- */
790
+ const results = await Promise.all(hosts.map(async (host) => {
828
791
  const res = await lUndici.get('http://' + host + ':' + globalConfig.rpcPort.toString() + '/' + lCrypto.aesEncrypt(lText.stringifyJson({
829
792
  'action': 'npm',
830
- 'time': time,
793
+ 'time': lTime.stamp(),
831
794
  'path': path
832
795
  }), globalConfig.rpcSecret), {
833
796
  'timeout': 330,
834
797
  });
835
798
  const content = await res.getContent();
836
799
  if (!content) {
837
- rtn[host] = { 'result': false, 'return': 'Timeout' };
838
- continue;
800
+ return [host, { 'result': false, 'return': 'Timeout' }];
839
801
  }
840
802
  const str = content.toString();
841
- if (str === 'Done') {
842
- rtn[host] = { 'result': true, 'return': 'Done' };
843
- }
844
- else {
845
- rtn[host] = { 'result': false, 'return': str };
803
+ if (str !== 'Done') {
846
804
  debug('[CORE][sendNpmInstall] rpc server content error:', str);
847
805
  }
848
- }
849
- return rtn;
806
+ return [host, { 'result': str === 'Done', 'return': str }];
807
+ }));
808
+ return Object.fromEntries(results);
850
809
  }
851
810
  /** --- 跨进程全局变量 --- */
852
811
  export const global = {};
@@ -871,31 +830,24 @@ export async function setGlobal(key, data, hosts) {
871
830
  if (hosts === 'config') {
872
831
  hosts = globalConfig.hosts;
873
832
  }
874
- // --- 局域网模式 ---
875
- const time = lTime.stamp();
876
- /** --- 返回成功的 host --- */
877
- const rtn = {};
878
- for (const host of hosts) {
833
+ /** --- 并行发送,各主机独立等待,结果保持输入顺序 --- */
834
+ const results = await Promise.all(hosts.map(async (host) => {
879
835
  const res = await lUndici.get('http://' + host + ':' + globalConfig.rpcPort.toString() + '/' + lCrypto.aesEncrypt(lText.stringifyJson({
880
836
  'action': 'global',
881
- 'time': time
837
+ 'time': lTime.stamp(),
838
+ 'key': key,
839
+ 'data': data
882
840
  }), globalConfig.rpcSecret), {
883
841
  'timeout': 5
884
842
  });
885
843
  const content = await res.getContent();
886
844
  if (!content) {
887
- rtn[host] = { 'result': false, 'return': 'Timeout' };
888
- continue;
845
+ return [host, { 'result': false, 'return': 'Timeout' }];
889
846
  }
890
847
  const str = content.toString();
891
- if (str === 'Done') {
892
- rtn[host] = { 'result': true, 'return': 'Done' };
893
- }
894
- else {
895
- rtn[host] = { 'result': false, 'return': str };
896
- }
897
- }
898
- return rtn;
848
+ return [host, { 'result': str === 'Done', 'return': str }];
849
+ }));
850
+ return Object.fromEntries(results);
899
851
  }
900
852
  /**
901
853
  * --- 移除某个跨线程/跨内网服务器全局变量 ---
@@ -924,12 +876,11 @@ export async function updateCode(sourcePath, path, hosts, config = true, strict
924
876
  if (!hosts?.length) {
925
877
  hosts = ['127.0.0.1'];
926
878
  }
927
- /** --- 返回成功的 host --- */
928
- const rtn = {};
929
- for (const host of hosts) {
879
+ /** --- 各主机使用独立上传流并行部署,结果保持输入顺序 --- */
880
+ const results = await Promise.all(hosts.map(async (host) => {
930
881
  const fd = lUndici.getFormData();
931
882
  if (!await fd.putFile('file', sourcePath)) {
932
- continue;
883
+ return;
933
884
  }
934
885
  fd.putString('path', path);
935
886
  fd.putString('config', config);
@@ -942,19 +893,12 @@ export async function updateCode(sourcePath, path, hosts, config = true, strict
942
893
  });
943
894
  const content = await res.getContent();
944
895
  if (!content) {
945
- rtn[host] = {
946
- 'result': false,
947
- 'return': 'Network error'
948
- };
949
- continue;
896
+ return [host, { 'result': false, 'return': 'Network error' }];
950
897
  }
951
898
  const str = content.toString();
952
- rtn[host] = {
953
- 'result': str === 'Done' ? true : false,
954
- 'return': str
955
- };
956
- }
957
- return rtn;
899
+ return [host, { 'result': str === 'Done', 'return': str }];
900
+ }));
901
+ return Object.fromEntries(results.filter(result => result !== undefined));
958
902
  }
959
903
  /**
960
904
  * --- 向本机或局域网 RPC 发送项目配置更新操作 ---
@@ -971,14 +915,11 @@ export async function sendProject(path, key, value, hosts) {
971
915
  if (!hosts?.length) {
972
916
  hosts = ['127.0.0.1'];
973
917
  }
974
- // --- 局域网模式 ---
975
- const time = lTime.stamp();
976
- /** --- 返回成功的 host --- */
977
- const rtn = {};
978
- for (const host of hosts) {
918
+ /** --- 并行发送,各主机独立等待,结果保持输入顺序 --- */
919
+ const results = await Promise.all(hosts.map(async (host) => {
979
920
  const res = await lUndici.get('http://' + host + ':' + globalConfig.rpcPort.toString() + '/' + lCrypto.aesEncrypt(lText.stringifyJson({
980
921
  'action': 'project',
981
- 'time': time,
922
+ 'time': lTime.stamp(),
982
923
  'path': path,
983
924
  [key]: value
984
925
  }), globalConfig.rpcSecret), {
@@ -986,19 +927,15 @@ export async function sendProject(path, key, value, hosts) {
986
927
  });
987
928
  const content = await res.getContent();
988
929
  if (!content) {
989
- rtn[host] = { 'result': false, 'return': 'Timeout' };
990
- continue;
930
+ return [host, { 'result': false, 'return': 'Timeout' }];
991
931
  }
992
932
  const str = content.toString();
993
- if (str === 'Done') {
994
- rtn[host] = { 'result': true, 'return': 'Done' };
995
- }
996
- else {
997
- rtn[host] = { 'result': false, 'return': str };
933
+ if (str !== 'Done') {
998
934
  debug('[CORE][sendProject] rpc server content error:', str);
999
935
  }
1000
- }
1001
- return rtn;
936
+ return [host, { 'result': str === 'Done', 'return': str }];
937
+ }));
938
+ return Object.fromEntries(results);
1002
939
  }
1003
940
  /**
1004
941
  * --- 向本机或局域网 RPC 发送 package.json 更新操作 ---
@@ -1013,33 +950,26 @@ export async function sendPackage(content, hosts) {
1013
950
  if (!hosts?.length) {
1014
951
  hosts = ['127.0.0.1'];
1015
952
  }
1016
- // --- 局域网模式 ---
1017
- const time = lTime.stamp();
1018
- /** --- 返回成功的 host --- */
1019
- const rtn = {};
1020
- for (const host of hosts) {
953
+ /** --- 并行发送,各主机独立等待,结果保持输入顺序 --- */
954
+ const results = await Promise.all(hosts.map(async (host) => {
1021
955
  const res = await lUndici.get('http://' + host + ':' + globalConfig.rpcPort.toString() + '/' + lCrypto.aesEncrypt(lText.stringifyJson({
1022
956
  'action': 'package',
1023
- 'time': time,
957
+ 'time': lTime.stamp(),
1024
958
  'content': content
1025
959
  }), globalConfig.rpcSecret), {
1026
960
  'timeout': 5
1027
961
  });
1028
962
  const resContent = await res.getContent();
1029
963
  if (!resContent) {
1030
- rtn[host] = { 'result': false, 'return': 'Timeout' };
1031
- continue;
964
+ return [host, { 'result': false, 'return': 'Timeout' }];
1032
965
  }
1033
966
  const str = resContent.toString();
1034
- if (str === 'Done') {
1035
- rtn[host] = { 'result': true, 'return': 'Done' };
1036
- }
1037
- else {
1038
- rtn[host] = { 'result': false, 'return': str };
967
+ if (str !== 'Done') {
1039
968
  debug('[CORE][sendPackage] rpc server content error:', str);
1040
969
  }
1041
- }
1042
- return rtn;
970
+ return [host, { 'result': str === 'Done', 'return': str }];
971
+ }));
972
+ return Object.fromEntries(results);
1043
973
  }
1044
974
  /**
1045
975
  * --- 写入文件日志 ---
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maiyunnet/kebab",
3
- "version": "9.22.2",
3
+ "version": "9.22.4",
4
4
  "description": "Simple, easy-to-use, and fully-featured Node.js framework that is ready-to-use out of the box.",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -14,7 +14,8 @@
14
14
  "types": "./index.d.ts",
15
15
  "scripts": {
16
16
  "build-doc": "bash ./utils/build-doc.sh",
17
- "test:formdata": "node abox/test/formdata.mjs"
17
+ "test:formdata": "node abox/test/formdata.mjs",
18
+ "test:rpc": "node --test --test-isolation=none abox/test/rpc.mjs"
18
19
  },
19
20
  "bin": {
20
21
  "kebab": "./bin/kebab.js"
package/sys/ctr.d.ts CHANGED
@@ -423,11 +423,7 @@ export declare class Ctr {
423
423
  * --- 获取 formdata 的信息 ---
424
424
  * @param events 文件处理情况
425
425
  * @param limits 上传限制
426
- * @returns 是否解析成功;失败原因通过 limits.onError 通知,连接中断时可能无法发送响应
426
+ * @returns 是否解析成功;失败原因通过 events.onerror 通知,连接中断时可能无法发送响应
427
427
  */
428
- protected _handleFormData(events?: {
429
- onfilestart?: (name: string) => boolean | undefined;
430
- onfiledata?: (chunk: Buffer) => void;
431
- onfileend?: () => void;
432
- }, limits?: sRoute.IFormDataLimits): Promise<boolean>;
428
+ protected _handleFormData(events?: sRoute.IFormDataEvents, limits?: sRoute.IFormDataLimits): Promise<boolean>;
433
429
  }
package/sys/ctr.js CHANGED
@@ -971,7 +971,7 @@ export class Ctr {
971
971
  * --- 获取 formdata 的信息 ---
972
972
  * @param events 文件处理情况
973
973
  * @param limits 上传限制
974
- * @returns 是否解析成功;失败原因通过 limits.onError 通知,连接中断时可能无法发送响应
974
+ * @returns 是否解析成功;失败原因通过 events.onerror 通知,连接中断时可能无法发送响应
975
975
  */
976
976
  async _handleFormData(events = {}, limits = {}) {
977
977
  const rtn = await sRoute.getFormData(this._req, events, limits);
package/sys/master.js CHANGED
@@ -314,18 +314,22 @@ function createRpcListener() {
314
314
  res.end('Path not found');
315
315
  return;
316
316
  }
317
- // --- npm install 上限与 sendNpm 客户端超时一致,超时后终止,避免无限期运行 ---
317
+ // --- 两次安装共用 5 分钟预算,给 sendNpm 的 330 秒等待留出回传时间 ---
318
318
  const npmTimeout = 300_000;
319
+ const npmDeadline = Date.now() + npmTimeout;
319
320
  let rtn = await lCore.exec('npm i --omit=dev', {
320
321
  'cwd': msg.path,
321
322
  'timeout': npmTimeout,
322
323
  });
323
324
  if (rtn === false) {
324
325
  // --- 部分项目可能存在 peerDependencies 冲突,失败后降级为 legacy-peer-deps 再试一次 ---
325
- rtn = await lCore.exec('npm i --omit=dev --legacy-peer-deps', {
326
- 'cwd': msg.path,
327
- 'timeout': npmTimeout,
328
- });
326
+ const remaining = npmDeadline - Date.now();
327
+ if (remaining > 0) {
328
+ rtn = await lCore.exec('npm i --omit=dev --legacy-peer-deps', {
329
+ 'cwd': msg.path,
330
+ 'timeout': remaining,
331
+ });
332
+ }
329
333
  }
330
334
  if (rtn === false) {
331
335
  res.end('Exec failed');
package/sys/route.d.ts CHANGED
@@ -64,7 +64,18 @@ export interface IFormDataError {
64
64
  /** --- 触发的限制值;大小按字节,超时按毫秒,段数按个 --- */
65
65
  'limit'?: number;
66
66
  }
67
- /** --- multipart 上传限制及失败通知 --- */
67
+ /** --- multipart 文件处理及失败通知 --- */
68
+ export interface IFormDataEvents {
69
+ /** --- 文件开始上传时触发,返回 true 则跳过该文件的保存 --- */
70
+ onfilestart?: (name: string) => boolean | undefined;
71
+ /** --- 文件上传时触发,仅 start 返回 true 时触发 --- */
72
+ onfiledata?: (chunk: Buffer) => void;
73
+ /** --- 文件上传结束时触发,仅 start 返回 true 时触发 --- */
74
+ onfileend?: () => void;
75
+ /** --- 首次失败时通知一次;原有 false 返回值不变,连接中断时响应可能无法送达 --- */
76
+ onerror?: (error: IFormDataError) => void;
77
+ }
78
+ /** --- multipart 上传限制 --- */
68
79
  export interface IFormDataLimits {
69
80
  /** --- 单个文件最大字节数 --- */
70
81
  'maxFileSize'?: number;
@@ -80,26 +91,15 @@ export interface IFormDataLimits {
80
91
  'maxParts'?: number;
81
92
  /** --- 整体请求超时时间(毫秒),默认 5 分钟,设为 0 禁用超时 --- */
82
93
  'timeout'?: number;
83
- /** --- 首次失败时通知一次;原有 false 返回值不变,连接中断时响应可能无法送达 --- */
84
- 'onError'?: (error: IFormDataError) => void;
85
94
  }
86
95
  /**
87
96
  * --- 获取 formdata 的 post ---
88
97
  * @param req 请求头
89
98
  * @param events 文件处理情况
90
99
  * @param limits 文件上传限制
91
- * @returns 字段和临时文件;失败返回 false,并通过 limits.onError 通知首次失败原因
100
+ * @returns 字段和临时文件;失败返回 false,并通过 events.onerror 通知首次失败原因
92
101
  */
93
- export declare function getFormData(req: http2.Http2ServerRequest | http.IncomingMessage, events?: {
94
- /**
95
- * --- 文件开始上传时触发,返回 true 则跳过该文件的保存 ---
96
- */
97
- onfilestart?: (name: string) => boolean | undefined;
98
- /** --- 文件上传时触发,仅 start 返回 true 时触发 --- */
99
- onfiledata?: (chunk: Buffer) => void;
100
- /** --- 文件上传结束时触发,仅 start 返回 true 时触发 --- */
101
- onfileend?: () => void;
102
- }, limits?: IFormDataLimits): Promise<{
102
+ export declare function getFormData(req: http2.Http2ServerRequest | http.IncomingMessage, events?: IFormDataEvents, limits?: IFormDataLimits): Promise<{
103
103
  'post': Record<string, kebab.Json>;
104
104
  'files': Record<string, kebab.IPostFile | kebab.IPostFile[]>;
105
105
  } | false>;
package/sys/route.js CHANGED
@@ -964,7 +964,7 @@ export function getPost(req) {
964
964
  * @param req 请求头
965
965
  * @param events 文件处理情况
966
966
  * @param limits 文件上传限制
967
- * @returns 字段和临时文件;失败返回 false,并通过 limits.onError 通知首次失败原因
967
+ * @returns 字段和临时文件;失败返回 false,并通过 events.onerror 通知首次失败原因
968
968
  */
969
969
  export function getFormData(req, events = {}, limits = {}) {
970
970
  return new Promise(resolve => {
@@ -991,7 +991,7 @@ export function getFormData(req, events = {}, limits = {}) {
991
991
  /** --- 获取的 boundary 文本 --- */
992
992
  const boundary = boundaryMatch[1] ?? boundaryMatch[2];
993
993
  if (!boundary || (boundary.length > 200) || /[\r\n]/.test(boundary)) {
994
- limits.onError?.({ 'code': 'INVALID_BOUNDARY' });
994
+ events.onerror?.({ 'code': 'INVALID_BOUNDARY' });
995
995
  resolve(false);
996
996
  return;
997
997
  }
@@ -1038,20 +1038,17 @@ export function getFormData(req, events = {}, limits = {}) {
1038
1038
  let readEnd = false;
1039
1039
  /** --- 是否有文件被限制拒绝(整体返回 false) --- */
1040
1040
  let rejected = false;
1041
- /** --- 保留首次失败,避免清理产生的流错误覆盖实际原因 --- */
1042
- let failure;
1043
1041
  /**
1044
1042
  * --- 拒绝本次上传,继续读取请求以便正常返回错误响应 ---
1045
1043
  * @param error 首次失败原因及对应限制
1046
1044
  * @returns 无返回值
1047
1045
  */
1048
1046
  function reject(error) {
1049
- rejected = true;
1050
- if (failure) {
1047
+ if (rejected) {
1051
1048
  return;
1052
1049
  }
1053
- failure = error;
1054
- limits.onError?.(error);
1050
+ rejected = true;
1051
+ events.onerror?.(error);
1055
1052
  if (error.code !== 'REQUEST_ABORTED') {
1056
1053
  lCore.log({}, `[ROUTE][GETFORMDATA] rejected: ${error.code}, limit: ${error.limit ?? '-'}`, '-error');
1057
1054
  }
@@ -1118,7 +1115,6 @@ export function getFormData(req, events = {}, limits = {}) {
1118
1115
  reject({ 'code': 'TIMEOUT', 'limit': timeoutMs });
1119
1116
  cleanupActiveFile();
1120
1117
  lCore.debug('[ROUTE][GETFORMDATA] formdata request timeout');
1121
- lCore.log({}, '[ROUTE][GETFORMDATA] formdata request timeout after ' + timeoutMs + 'ms', '-error');
1122
1118
  cleanupFiles();
1123
1119
  resolve(false);
1124
1120
  }, timeoutMs);
@@ -1236,7 +1232,6 @@ export function getFormData(req, events = {}, limits = {}) {
1236
1232
  ftmpName = '';
1237
1233
  }
1238
1234
  --writeFileLength;
1239
- req.resume();
1240
1235
  lCore.log({}, `[ROUTE][GETFORMDATA] temporary file error: ${error.message}`, '-error');
1241
1236
  if (readEnd) {
1242
1237
  finalize();