@maiyunnet/kebab 9.3.13 → 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 +119 -55
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/lib/core.d.ts +5 -0
- package/lib/core.js +27 -14
- package/lib/text.d.ts +2 -0
- package/lib/text.js +4 -0
- 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
|
|
|
@@ -3258,7 +3258,7 @@ lib/core/functions/clone.md
|
|
|
3258
3258
|
|
|
3259
3259
|
> **clone**\<`T`\>(`obj`): `T`
|
|
3260
3260
|
|
|
3261
|
-
Defined in: [lib/core.ts:
|
|
3261
|
+
Defined in: [lib/core.ts:1124](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1124)
|
|
3262
3262
|
|
|
3263
3263
|
完整的克隆一份数组/对象
|
|
3264
3264
|
|
|
@@ -3322,7 +3322,7 @@ lib/core/functions/debug.md
|
|
|
3322
3322
|
|
|
3323
3323
|
> **debug**(`message?`, ...`optionalParams`): `void`
|
|
3324
3324
|
|
|
3325
|
-
Defined in: [lib/core.ts:
|
|
3325
|
+
Defined in: [lib/core.ts:1158](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1158)
|
|
3326
3326
|
|
|
3327
3327
|
打印调试信息,线上环境不会打印
|
|
3328
3328
|
|
|
@@ -3357,7 +3357,7 @@ lib/core/functions/display.md
|
|
|
3357
3357
|
|
|
3358
3358
|
> **display**(`message?`, ...`optionalParams`): `void`
|
|
3359
3359
|
|
|
3360
|
-
Defined in: [lib/core.ts:
|
|
3360
|
+
Defined in: [lib/core.ts:1171](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1171)
|
|
3361
3361
|
|
|
3362
3362
|
向控制台直接显示内容,一般情况下禁止使用
|
|
3363
3363
|
|
|
@@ -3392,7 +3392,7 @@ lib/core/functions/emptyObject.md
|
|
|
3392
3392
|
|
|
3393
3393
|
> **emptyObject**(`obj`, `deep?`): `void`
|
|
3394
3394
|
|
|
3395
|
-
Defined in: [lib/core.ts:
|
|
3395
|
+
Defined in: [lib/core.ts:453](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L453)
|
|
3396
3396
|
|
|
3397
3397
|
将对象的所有属性清除包括键,不会破坏引用关系,对象变量依然保证是引用状态
|
|
3398
3398
|
|
|
@@ -3427,7 +3427,7 @@ lib/core/functions/exec.md
|
|
|
3427
3427
|
|
|
3428
3428
|
> **exec**(`command`, `options?`): `Promise`\<`string` \| `false`\>
|
|
3429
3429
|
|
|
3430
|
-
Defined in: [lib/core.ts:
|
|
3430
|
+
Defined in: [lib/core.ts:515](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L515)
|
|
3431
3431
|
|
|
3432
3432
|
执行命令行
|
|
3433
3433
|
|
|
@@ -3462,7 +3462,7 @@ lib/core/functions/getLog.md
|
|
|
3462
3462
|
|
|
3463
3463
|
> **getLog**(`opt`): `Promise`\<`false` \| `string`[][] \| `null`\>
|
|
3464
3464
|
|
|
3465
|
-
Defined in: [lib/core.ts:
|
|
3465
|
+
Defined in: [lib/core.ts:1031](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1031)
|
|
3466
3466
|
|
|
3467
3467
|
获取日志内容为一个数组
|
|
3468
3468
|
|
|
@@ -3555,6 +3555,41 @@ Defined in: [lib/core.ts:358](https://github.com/maiyunnet/kebab/blob/master/lib
|
|
|
3555
3555
|
|
|
3556
3556
|
`string`
|
|
3557
3557
|
|
|
3558
|
+
lib/core/functions/ips.md
|
|
3559
|
+
---
|
|
3560
|
+
|
|
3561
|
+
[**Documents for @maiyunnet/kebab**](../../../index.md)
|
|
3562
|
+
|
|
3563
|
+
***
|
|
3564
|
+
|
|
3565
|
+
[Documents for @maiyunnet/kebab](../../../index.md) / [lib/core](../index.md) / ips
|
|
3566
|
+
|
|
3567
|
+
# Function: ips()
|
|
3568
|
+
|
|
3569
|
+
> **ips**(`ctr`): `object`
|
|
3570
|
+
|
|
3571
|
+
Defined in: [lib/core.ts:383](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L383)
|
|
3572
|
+
|
|
3573
|
+
获取 CF 和 X 的 IP
|
|
3574
|
+
|
|
3575
|
+
## Parameters
|
|
3576
|
+
|
|
3577
|
+
### ctr
|
|
3578
|
+
|
|
3579
|
+
`IncomingHttpHeaders` \| [`Ctr`](../../../sys/ctr/classes/Ctr.md)
|
|
3580
|
+
|
|
3581
|
+
## Returns
|
|
3582
|
+
|
|
3583
|
+
`object`
|
|
3584
|
+
|
|
3585
|
+
### cf
|
|
3586
|
+
|
|
3587
|
+
> **cf**: `string`
|
|
3588
|
+
|
|
3589
|
+
### x
|
|
3590
|
+
|
|
3591
|
+
> **x**: `string`
|
|
3592
|
+
|
|
3558
3593
|
lib/core/functions/loadEnv.md
|
|
3559
3594
|
---
|
|
3560
3595
|
|
|
@@ -3568,7 +3603,7 @@ lib/core/functions/loadEnv.md
|
|
|
3568
3603
|
|
|
3569
3604
|
> **loadEnv**(`dir`): `Promise`\<`void`\>
|
|
3570
3605
|
|
|
3571
|
-
Defined in: [lib/core.ts:
|
|
3606
|
+
Defined in: [lib/core.ts:1223](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1223)
|
|
3572
3607
|
|
|
3573
3608
|
加载 .env 文件到 process.env,若文件不存在则跳过
|
|
3574
3609
|
|
|
@@ -3597,7 +3632,7 @@ lib/core/functions/log.md
|
|
|
3597
3632
|
|
|
3598
3633
|
> **log**(`opt`, `msg`, `fend?`): `void`
|
|
3599
3634
|
|
|
3600
|
-
Defined in: [lib/core.ts:
|
|
3635
|
+
Defined in: [lib/core.ts:920](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L920)
|
|
3601
3636
|
|
|
3602
3637
|
写入文件日志
|
|
3603
3638
|
|
|
@@ -3638,7 +3673,7 @@ lib/core/functions/ls.md
|
|
|
3638
3673
|
|
|
3639
3674
|
> **ls**(`opt`): `Promise`\<`object`[]\>
|
|
3640
3675
|
|
|
3641
|
-
Defined in: [lib/core.ts:
|
|
3676
|
+
Defined in: [lib/core.ts:1085](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1085)
|
|
3642
3677
|
|
|
3643
3678
|
获取目录内文件/文件夹列表
|
|
3644
3679
|
|
|
@@ -3744,7 +3779,7 @@ lib/core/functions/objectSort.md
|
|
|
3744
3779
|
|
|
3745
3780
|
> **objectSort**\<`T`\>(`o`): `T`
|
|
3746
3781
|
|
|
3747
|
-
Defined in: [lib/core.ts:
|
|
3782
|
+
Defined in: [lib/core.ts:434](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L434)
|
|
3748
3783
|
|
|
3749
3784
|
将对象进行升序排列
|
|
3750
3785
|
|
|
@@ -3779,7 +3814,7 @@ lib/core/functions/passThroughAppend.md
|
|
|
3779
3814
|
|
|
3780
3815
|
> **passThroughAppend**(`passThrough`, `data`, `end?`): `Promise`\<`void`\>
|
|
3781
3816
|
|
|
3782
|
-
Defined in: [lib/core.ts:
|
|
3817
|
+
Defined in: [lib/core.ts:472](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L472)
|
|
3783
3818
|
|
|
3784
3819
|
调用前自行创建 passThrough,并且调用 pipe 绑定到应该绑定的对象,然后再调用本函数
|
|
3785
3820
|
|
|
@@ -3931,7 +3966,7 @@ lib/core/functions/realIP.md
|
|
|
3931
3966
|
|
|
3932
3967
|
> **realIP**(`ctr`, `name?`): `string`
|
|
3933
3968
|
|
|
3934
|
-
Defined in: [lib/core.ts:
|
|
3969
|
+
Defined in: [lib/core.ts:406](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L406)
|
|
3935
3970
|
|
|
3936
3971
|
获取直连 IP(安全 IP)
|
|
3937
3972
|
|
|
@@ -3964,7 +3999,7 @@ lib/core/functions/removeGlobal.md
|
|
|
3964
3999
|
|
|
3965
4000
|
> **removeGlobal**(`key`, `hosts?`): `Promise`\<`string`[]\>
|
|
3966
4001
|
|
|
3967
|
-
Defined in: [lib/core.ts:
|
|
4002
|
+
Defined in: [lib/core.ts:750](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L750)
|
|
3968
4003
|
|
|
3969
4004
|
移除某个跨线程/跨内网服务器全局变量
|
|
3970
4005
|
|
|
@@ -3999,7 +4034,7 @@ lib/core/functions/resolveEnvVars.md
|
|
|
3999
4034
|
|
|
4000
4035
|
> **resolveEnvVars**(`obj`): `void`
|
|
4001
4036
|
|
|
4002
|
-
Defined in: [lib/core.ts:
|
|
4037
|
+
Defined in: [lib/core.ts:1253](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1253)
|
|
4003
4038
|
|
|
4004
4039
|
将配置对象中的 ${ENV_VAR} 占位符替换为 process.env 的值
|
|
4005
4040
|
|
|
@@ -4028,7 +4063,7 @@ lib/core/functions/sendNpm.md
|
|
|
4028
4063
|
|
|
4029
4064
|
> **sendNpm**(`path`, `hosts?`): `Promise`\<`string`[]\>
|
|
4030
4065
|
|
|
4031
|
-
Defined in: [lib/core.ts:
|
|
4066
|
+
Defined in: [lib/core.ts:663](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L663)
|
|
4032
4067
|
|
|
4033
4068
|
向本机或局域网 RPC 发送 npm install 操作
|
|
4034
4069
|
|
|
@@ -4063,7 +4098,7 @@ lib/core/functions/sendPackage.md
|
|
|
4063
4098
|
|
|
4064
4099
|
> **sendPackage**(`content`, `hosts?`): `Promise`\<`string`[]\>
|
|
4065
4100
|
|
|
4066
|
-
Defined in: [lib/core.ts:
|
|
4101
|
+
Defined in: [lib/core.ts:865](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L865)
|
|
4067
4102
|
|
|
4068
4103
|
向本机或局域网 RPC 发送 package.json 更新操作
|
|
4069
4104
|
|
|
@@ -4098,7 +4133,7 @@ lib/core/functions/sendPm2.md
|
|
|
4098
4133
|
|
|
4099
4134
|
> **sendPm2**(`name`, `action?`, `hosts?`): `Promise`\<`string`[]\>
|
|
4100
4135
|
|
|
4101
|
-
Defined in: [lib/core.ts:
|
|
4136
|
+
Defined in: [lib/core.ts:620](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L620)
|
|
4102
4137
|
|
|
4103
4138
|
向本机或局域网 RPC 发送 PM2 操作
|
|
4104
4139
|
|
|
@@ -4139,7 +4174,7 @@ lib/core/functions/sendProject.md
|
|
|
4139
4174
|
|
|
4140
4175
|
> **sendProject**(`path`, `key`, `value`, `hosts?`): `Promise`\<`string`[]\>
|
|
4141
4176
|
|
|
4142
|
-
Defined in: [lib/core.ts:
|
|
4177
|
+
Defined in: [lib/core.ts:822](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L822)
|
|
4143
4178
|
|
|
4144
4179
|
向本机或局域网 RPC 发送项目配置更新操作
|
|
4145
4180
|
|
|
@@ -4186,7 +4221,7 @@ lib/core/functions/sendReload.md
|
|
|
4186
4221
|
|
|
4187
4222
|
> **sendReload**(`hosts?`): `Promise`\<`string`[]\>
|
|
4188
4223
|
|
|
4189
|
-
Defined in: [lib/core.ts:
|
|
4224
|
+
Defined in: [lib/core.ts:535](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L535)
|
|
4190
4225
|
|
|
4191
4226
|
向主进程(或局域网同代码机子)发送广播将进行 reload 操作,等待回传
|
|
4192
4227
|
主要作用除代码热更新以外的其他情况
|
|
@@ -4214,7 +4249,7 @@ lib/core/functions/sendRestart.md
|
|
|
4214
4249
|
|
|
4215
4250
|
> **sendRestart**(`hosts?`): `Promise`\<`string`[]\>
|
|
4216
4251
|
|
|
4217
|
-
Defined in: [lib/core.ts:
|
|
4252
|
+
Defined in: [lib/core.ts:575](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L575)
|
|
4218
4253
|
|
|
4219
4254
|
向主进程(或局域网同代码机子)发送广播将进行 restart 操作,停止监听并启动新进程,老进程在连接全部断开后自行销毁
|
|
4220
4255
|
主要用作不间断的代码热更新
|
|
@@ -4289,7 +4324,7 @@ lib/core/functions/setGlobal.md
|
|
|
4289
4324
|
|
|
4290
4325
|
> **setGlobal**(`key`, `data`, `hosts?`): `Promise`\<`string`[]\>
|
|
4291
4326
|
|
|
4292
|
-
Defined in: [lib/core.ts:
|
|
4327
|
+
Defined in: [lib/core.ts:709](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L709)
|
|
4293
4328
|
|
|
4294
4329
|
设置跨线程/指定的局域网主机的全局变量
|
|
4295
4330
|
|
|
@@ -4330,7 +4365,7 @@ lib/core/functions/sleep.md
|
|
|
4330
4365
|
|
|
4331
4366
|
> **sleep**(`ms`): `Promise`\<`void`\>
|
|
4332
4367
|
|
|
4333
|
-
Defined in: [lib/core.ts:
|
|
4368
|
+
Defined in: [lib/core.ts:422](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L422)
|
|
4334
4369
|
|
|
4335
4370
|
间隔一段时间
|
|
4336
4371
|
|
|
@@ -4388,7 +4423,7 @@ lib/core/functions/updateCode.md
|
|
|
4388
4423
|
|
|
4389
4424
|
> **updateCode**(`sourcePath`, `path`, `hosts?`, `config?`, `strict?`): `Promise`\<`Record`\<`string`, \{ `result`: `boolean`; `return`: `string`; \}\>\>
|
|
4390
4425
|
|
|
4391
|
-
Defined in: [lib/core.ts:
|
|
4426
|
+
Defined in: [lib/core.ts:762](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L762)
|
|
4392
4427
|
|
|
4393
4428
|
上传并覆盖代码文件,config.json、kebab.json、.js.map、.ts, .gitignore 不会被覆盖和新创建
|
|
4394
4429
|
|
|
@@ -4441,7 +4476,7 @@ lib/core/functions/writeEventStreamHead.md
|
|
|
4441
4476
|
|
|
4442
4477
|
> **writeEventStreamHead**(`res`): `void`
|
|
4443
4478
|
|
|
4444
|
-
Defined in: [lib/core.ts:
|
|
4479
|
+
Defined in: [lib/core.ts:1193](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1193)
|
|
4445
4480
|
|
|
4446
4481
|
## Parameters
|
|
4447
4482
|
|
|
@@ -4466,7 +4501,7 @@ lib/core/functions/writeHead.md
|
|
|
4466
4501
|
|
|
4467
4502
|
> **writeHead**(`res`, `statusCode`, `headers?`): `void`
|
|
4468
4503
|
|
|
4469
|
-
Defined in: [lib/core.ts:
|
|
4504
|
+
Defined in: [lib/core.ts:1182](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1182)
|
|
4470
4505
|
|
|
4471
4506
|
让 res 发送头部(前提是头部没有被发送才能调用本方法
|
|
4472
4507
|
|
|
@@ -4507,7 +4542,7 @@ lib/core/functions/write.md
|
|
|
4507
4542
|
|
|
4508
4543
|
> **write**(`res`, `data`): `void`
|
|
4509
4544
|
|
|
4510
|
-
Defined in: [lib/core.ts:
|
|
4545
|
+
Defined in: [lib/core.ts:1205](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1205)
|
|
4511
4546
|
|
|
4512
4547
|
向 res 发送数据
|
|
4513
4548
|
|
|
@@ -4577,6 +4612,7 @@ lib/core/index.md
|
|
|
4577
4612
|
- [exec](functions/exec.md)
|
|
4578
4613
|
- [getLog](functions/getLog.md)
|
|
4579
4614
|
- [ip](functions/ip.md)
|
|
4615
|
+
- [ips](functions/ips.md)
|
|
4580
4616
|
- [loadEnv](functions/loadEnv.md)
|
|
4581
4617
|
- [log](functions/log.md)
|
|
4582
4618
|
- [ls](functions/ls.md)
|
|
@@ -4678,7 +4714,7 @@ lib/core/interfaces/ILogOptions.md
|
|
|
4678
4714
|
|
|
4679
4715
|
# Interface: ILogOptions
|
|
4680
4716
|
|
|
4681
|
-
Defined in: [lib/core.ts:
|
|
4717
|
+
Defined in: [lib/core.ts:903](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L903)
|
|
4682
4718
|
|
|
4683
4719
|
log 设置的选项
|
|
4684
4720
|
|
|
@@ -4688,7 +4724,7 @@ log 设置的选项
|
|
|
4688
4724
|
|
|
4689
4725
|
> `optional` **cookie?**: `Record`\<`string`, `string`\>
|
|
4690
4726
|
|
|
4691
|
-
Defined in: [lib/core.ts:
|
|
4727
|
+
Defined in: [lib/core.ts:909](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L909)
|
|
4692
4728
|
|
|
4693
4729
|
***
|
|
4694
4730
|
|
|
@@ -4696,7 +4732,7 @@ Defined in: [lib/core.ts:895](https://github.com/maiyunnet/kebab/blob/master/lib
|
|
|
4696
4732
|
|
|
4697
4733
|
> `optional` **get?**: `Record`\<`string`, `any`\>
|
|
4698
4734
|
|
|
4699
|
-
Defined in: [lib/core.ts:
|
|
4735
|
+
Defined in: [lib/core.ts:908](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L908)
|
|
4700
4736
|
|
|
4701
4737
|
***
|
|
4702
4738
|
|
|
@@ -4704,7 +4740,7 @@ Defined in: [lib/core.ts:894](https://github.com/maiyunnet/kebab/blob/master/lib
|
|
|
4704
4740
|
|
|
4705
4741
|
> `optional` **headers?**: `IncomingHttpHeaders`
|
|
4706
4742
|
|
|
4707
|
-
Defined in: [lib/core.ts:
|
|
4743
|
+
Defined in: [lib/core.ts:911](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L911)
|
|
4708
4744
|
|
|
4709
4745
|
***
|
|
4710
4746
|
|
|
@@ -4712,7 +4748,7 @@ Defined in: [lib/core.ts:897](https://github.com/maiyunnet/kebab/blob/master/lib
|
|
|
4712
4748
|
|
|
4713
4749
|
> `optional` **hostname?**: `string`
|
|
4714
4750
|
|
|
4715
|
-
Defined in: [lib/core.ts:
|
|
4751
|
+
Defined in: [lib/core.ts:906](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L906)
|
|
4716
4752
|
|
|
4717
4753
|
***
|
|
4718
4754
|
|
|
@@ -4720,7 +4756,7 @@ Defined in: [lib/core.ts:892](https://github.com/maiyunnet/kebab/blob/master/lib
|
|
|
4720
4756
|
|
|
4721
4757
|
> `optional` **path?**: `string`
|
|
4722
4758
|
|
|
4723
|
-
Defined in: [lib/core.ts:
|
|
4759
|
+
Defined in: [lib/core.ts:904](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L904)
|
|
4724
4760
|
|
|
4725
4761
|
***
|
|
4726
4762
|
|
|
@@ -4728,7 +4764,7 @@ Defined in: [lib/core.ts:890](https://github.com/maiyunnet/kebab/blob/master/lib
|
|
|
4728
4764
|
|
|
4729
4765
|
> `optional` **req?**: `IncomingMessage` \| `Http2ServerRequest` \| `null`
|
|
4730
4766
|
|
|
4731
|
-
Defined in: [lib/core.ts:
|
|
4767
|
+
Defined in: [lib/core.ts:907](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L907)
|
|
4732
4768
|
|
|
4733
4769
|
***
|
|
4734
4770
|
|
|
@@ -4736,7 +4772,7 @@ Defined in: [lib/core.ts:893](https://github.com/maiyunnet/kebab/blob/master/lib
|
|
|
4736
4772
|
|
|
4737
4773
|
> `optional` **session?**: `Record`\<`string`, `any`\>
|
|
4738
4774
|
|
|
4739
|
-
Defined in: [lib/core.ts:
|
|
4775
|
+
Defined in: [lib/core.ts:910](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L910)
|
|
4740
4776
|
|
|
4741
4777
|
***
|
|
4742
4778
|
|
|
@@ -4744,7 +4780,7 @@ Defined in: [lib/core.ts:896](https://github.com/maiyunnet/kebab/blob/master/lib
|
|
|
4744
4780
|
|
|
4745
4781
|
> `optional` **urlFull?**: `string`
|
|
4746
4782
|
|
|
4747
|
-
Defined in: [lib/core.ts:
|
|
4783
|
+
Defined in: [lib/core.ts:905](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L905)
|
|
4748
4784
|
|
|
4749
4785
|
lib/core/type-aliases/TPm2Action.md
|
|
4750
4786
|
---
|
|
@@ -4759,7 +4795,7 @@ lib/core/type-aliases/TPm2Action.md
|
|
|
4759
4795
|
|
|
4760
4796
|
> **TPm2Action** = `"start"` \| `"stop"` \| `"restart"`
|
|
4761
4797
|
|
|
4762
|
-
Defined in: [lib/core.ts:
|
|
4798
|
+
Defined in: [lib/core.ts:612](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L612)
|
|
4763
4799
|
|
|
4764
4800
|
PM2 操作类型
|
|
4765
4801
|
|
|
@@ -4833,7 +4869,7 @@ lib/core/variables/global.md
|
|
|
4833
4869
|
|
|
4834
4870
|
> `const` **global**: `Record`\<`string`, `any`\> = `{}`
|
|
4835
4871
|
|
|
4836
|
-
Defined in: [lib/core.ts:
|
|
4872
|
+
Defined in: [lib/core.ts:701](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L701)
|
|
4837
4873
|
|
|
4838
4874
|
跨进程全局变量
|
|
4839
4875
|
|
|
@@ -5003,7 +5039,7 @@ lib/core/variables/REAL_IP_CF.md
|
|
|
5003
5039
|
|
|
5004
5040
|
> `const` **REAL\_IP\_CF**: `"cf-connecting-ip"` = `'cf-connecting-ip'`
|
|
5005
5041
|
|
|
5006
|
-
Defined in: [lib/core.ts:
|
|
5042
|
+
Defined in: [lib/core.ts:399](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L399)
|
|
5007
5043
|
|
|
5008
5044
|
使用的是 Cloudflare
|
|
5009
5045
|
|
|
@@ -5020,7 +5056,7 @@ lib/core/variables/REAL_IP_X.md
|
|
|
5020
5056
|
|
|
5021
5057
|
> `const` **REAL\_IP\_X**: `"x-forwarded-for"` = `'x-forwarded-for'`
|
|
5022
5058
|
|
|
5023
|
-
Defined in: [lib/core.ts:
|
|
5059
|
+
Defined in: [lib/core.ts:397](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L397)
|
|
5024
5060
|
|
|
5025
5061
|
使用 X-Forwarded-For 的 CDN 厂商
|
|
5026
5062
|
|
|
@@ -15816,6 +15852,33 @@ lib/ssh/shell/index.md
|
|
|
15816
15852
|
|
|
15817
15853
|
- [Connection](classes/Connection.md)
|
|
15818
15854
|
|
|
15855
|
+
lib/text/functions/csvescape.md
|
|
15856
|
+
---
|
|
15857
|
+
|
|
15858
|
+
[**Documents for @maiyunnet/kebab**](../../../index.md)
|
|
15859
|
+
|
|
15860
|
+
***
|
|
15861
|
+
|
|
15862
|
+
[Documents for @maiyunnet/kebab](../../../index.md) / [lib/text](../index.md) / csvescape
|
|
15863
|
+
|
|
15864
|
+
# Function: csvescape()
|
|
15865
|
+
|
|
15866
|
+
> **csvescape**(`str`): `string`
|
|
15867
|
+
|
|
15868
|
+
Defined in: [lib/text.ts:497](https://github.com/maiyunnet/kebab/blob/master/lib/text.ts#L497)
|
|
15869
|
+
|
|
15870
|
+
CSV 特殊字符转换为实体字符
|
|
15871
|
+
|
|
15872
|
+
## Parameters
|
|
15873
|
+
|
|
15874
|
+
### str
|
|
15875
|
+
|
|
15876
|
+
`string`
|
|
15877
|
+
|
|
15878
|
+
## Returns
|
|
15879
|
+
|
|
15880
|
+
`string`
|
|
15881
|
+
|
|
15819
15882
|
lib/text/functions/getFileExt.md
|
|
15820
15883
|
---
|
|
15821
15884
|
|
|
@@ -15829,7 +15892,7 @@ lib/text/functions/getFileExt.md
|
|
|
15829
15892
|
|
|
15830
15893
|
> **getFileExt**(`path`): `string`
|
|
15831
15894
|
|
|
15832
|
-
Defined in: [lib/text.ts:
|
|
15895
|
+
Defined in: [lib/text.ts:538](https://github.com/maiyunnet/kebab/blob/master/lib/text.ts#L538)
|
|
15833
15896
|
|
|
15834
15897
|
获取文件后缀
|
|
15835
15898
|
|
|
@@ -15858,7 +15921,7 @@ lib/text/functions/getFileNameExt.md
|
|
|
15858
15921
|
|
|
15859
15922
|
> **getFileNameExt**(`path`): `object`
|
|
15860
15923
|
|
|
15861
|
-
Defined in: [lib/text.ts:
|
|
15924
|
+
Defined in: [lib/text.ts:551](https://github.com/maiyunnet/kebab/blob/master/lib/text.ts#L551)
|
|
15862
15925
|
|
|
15863
15926
|
获取文件名和后缀
|
|
15864
15927
|
|
|
@@ -15895,7 +15958,7 @@ lib/text/functions/getFilename.md
|
|
|
15895
15958
|
|
|
15896
15959
|
> **getFilename**(`path`, `ext?`): `string`
|
|
15897
15960
|
|
|
15898
|
-
Defined in: [lib/text.ts:
|
|
15961
|
+
Defined in: [lib/text.ts:518](https://github.com/maiyunnet/kebab/blob/master/lib/text.ts#L518)
|
|
15899
15962
|
|
|
15900
15963
|
获取文件名
|
|
15901
15964
|
|
|
@@ -15959,7 +16022,7 @@ lib/text/functions/int2str.md
|
|
|
15959
16022
|
|
|
15960
16023
|
> **int2str**(`int`, `digits?`, `decimal?`): `string`
|
|
15961
16024
|
|
|
15962
|
-
Defined in: [lib/text.ts:
|
|
16025
|
+
Defined in: [lib/text.ts:751](https://github.com/maiyunnet/kebab/blob/master/lib/text.ts#L751)
|
|
15963
16026
|
|
|
15964
16027
|
为解决精度问题,将整数转换为小数字符串
|
|
15965
16028
|
以下几个示例都是当 digits 为 3、decimal 为 2 时
|
|
@@ -16092,7 +16155,7 @@ lib/text/functions/isFalsy.md
|
|
|
16092
16155
|
|
|
16093
16156
|
> **isFalsy**(`val`): `val is TFalsy`
|
|
16094
16157
|
|
|
16095
|
-
Defined in: [lib/text.ts:
|
|
16158
|
+
Defined in: [lib/text.ts:702](https://github.com/maiyunnet/kebab/blob/master/lib/text.ts#L702)
|
|
16096
16159
|
|
|
16097
16160
|
判断一个值是否是虚假的(为 null/undefined/空字符串/false/0)
|
|
16098
16161
|
|
|
@@ -16233,7 +16296,7 @@ lib/text/functions/isRealPath.md
|
|
|
16233
16296
|
|
|
16234
16297
|
> **isRealPath**(`path`): `boolean`
|
|
16235
16298
|
|
|
16236
|
-
Defined in: [lib/text.ts:
|
|
16299
|
+
Defined in: [lib/text.ts:505](https://github.com/maiyunnet/kebab/blob/master/lib/text.ts#L505)
|
|
16237
16300
|
|
|
16238
16301
|
判断是否是绝对路径,是返回 true,相对路径返回 false
|
|
16239
16302
|
|
|
@@ -16262,7 +16325,7 @@ lib/text/functions/isTruthy.md
|
|
|
16262
16325
|
|
|
16263
16326
|
> **isTruthy**\<`T`\>(`val`): `val is Exclude<T, TFalsy>`
|
|
16264
16327
|
|
|
16265
|
-
Defined in: [lib/text.ts:
|
|
16328
|
+
Defined in: [lib/text.ts:710](https://github.com/maiyunnet/kebab/blob/master/lib/text.ts#L710)
|
|
16266
16329
|
|
|
16267
16330
|
判断一个值是否是真实的(不为 null/undefined/空字符串/false/0)
|
|
16268
16331
|
|
|
@@ -16297,7 +16360,7 @@ lib/text/functions/logicalOr.md
|
|
|
16297
16360
|
|
|
16298
16361
|
> **logicalOr**\<`T`, `T2`\>(`v1`, `v2`): `T` *extends* [`TFalsy`](../type-aliases/TFalsy.md) ? `T2` : `T`
|
|
16299
16362
|
|
|
16300
|
-
Defined in: [lib/text.ts:
|
|
16363
|
+
Defined in: [lib/text.ts:719](https://github.com/maiyunnet/kebab/blob/master/lib/text.ts#L719)
|
|
16301
16364
|
|
|
16302
16365
|
类似 || 运算符的效果
|
|
16303
16366
|
|
|
@@ -16482,7 +16545,7 @@ lib/text/functions/parseJson.md
|
|
|
16482
16545
|
|
|
16483
16546
|
> **parseJson**\<`T`\>(`str`): `false` \| `T`
|
|
16484
16547
|
|
|
16485
|
-
Defined in: [lib/text.ts:
|
|
16548
|
+
Defined in: [lib/text.ts:613](https://github.com/maiyunnet/kebab/blob/master/lib/text.ts#L613)
|
|
16486
16549
|
|
|
16487
16550
|
将字符串解析为对象,返回 false 代表解析失败,支持 BigInt
|
|
16488
16551
|
|
|
@@ -16681,7 +16744,7 @@ lib/text/functions/str2int.md
|
|
|
16681
16744
|
|
|
16682
16745
|
> **str2int**(`str`, `digits?`): `number`
|
|
16683
16746
|
|
|
16684
|
-
Defined in: [lib/text.ts:
|
|
16747
|
+
Defined in: [lib/text.ts:733](https://github.com/maiyunnet/kebab/blob/master/lib/text.ts#L733)
|
|
16685
16748
|
|
|
16686
16749
|
为解决精度问题,将字符串数字转换为整数显示
|
|
16687
16750
|
以下几个示例都是当 digits 为 2 时
|
|
@@ -16721,7 +16784,7 @@ lib/text/functions/stringifyBuffer.md
|
|
|
16721
16784
|
|
|
16722
16785
|
> **stringifyBuffer**(`buf`): `string`
|
|
16723
16786
|
|
|
16724
|
-
Defined in: [lib/text.ts:
|
|
16787
|
+
Defined in: [lib/text.ts:656](https://github.com/maiyunnet/kebab/blob/master/lib/text.ts#L656)
|
|
16725
16788
|
|
|
16726
16789
|
输出文本格式的 buffer
|
|
16727
16790
|
|
|
@@ -16750,7 +16813,7 @@ lib/text/functions/stringifyJson.md
|
|
|
16750
16813
|
|
|
16751
16814
|
> **stringifyJson**(`obj`, `space?`): `string`
|
|
16752
16815
|
|
|
16753
|
-
Defined in: [lib/text.ts:
|
|
16816
|
+
Defined in: [lib/text.ts:643](https://github.com/maiyunnet/kebab/blob/master/lib/text.ts#L643)
|
|
16754
16817
|
|
|
16755
16818
|
将对象转换为 json 字符串,返回 false 代表解析失败,支持 BigInt
|
|
16756
16819
|
|
|
@@ -16785,7 +16848,7 @@ lib/text/functions/stringifyResult.md
|
|
|
16785
16848
|
|
|
16786
16849
|
> **stringifyResult**(`rtn`): `string`
|
|
16787
16850
|
|
|
16788
|
-
Defined in: [lib/text.ts:
|
|
16851
|
+
Defined in: [lib/text.ts:573](https://github.com/maiyunnet/kebab/blob/master/lib/text.ts#L573)
|
|
16789
16852
|
|
|
16790
16853
|
将普通的返回 JSON 对象序列化为字符串
|
|
16791
16854
|
|
|
@@ -16814,7 +16877,7 @@ lib/text/functions/trimJson.md
|
|
|
16814
16877
|
|
|
16815
16878
|
> **trimJson**(`json`): `any`
|
|
16816
16879
|
|
|
16817
|
-
Defined in: [lib/text.ts:
|
|
16880
|
+
Defined in: [lib/text.ts:664](https://github.com/maiyunnet/kebab/blob/master/lib/text.ts#L664)
|
|
16818
16881
|
|
|
16819
16882
|
递归删除 json 中的字符串首尾空格,会返回一个新的对象
|
|
16820
16883
|
|
|
@@ -16921,6 +16984,7 @@ lib/text/index.md
|
|
|
16921
16984
|
|
|
16922
16985
|
## Functions
|
|
16923
16986
|
|
|
16987
|
+
- [csvescape](functions/csvescape.md)
|
|
16924
16988
|
- [getFileExt](functions/getFileExt.md)
|
|
16925
16989
|
- [getFilename](functions/getFilename.md)
|
|
16926
16990
|
- [getFileNameExt](functions/getFileNameExt.md)
|
|
@@ -17014,7 +17078,7 @@ lib/text/type-aliases/TFalsy.md
|
|
|
17014
17078
|
|
|
17015
17079
|
> **TFalsy** = `false` \| `""` \| `0` \| `null` \| `undefined` \| *typeof* `NaN`
|
|
17016
17080
|
|
|
17017
|
-
Defined in: [lib/text.ts:
|
|
17081
|
+
Defined in: [lib/text.ts:696](https://github.com/maiyunnet/kebab/blob/master/lib/text.ts#L696)
|
|
17018
17082
|
|
|
17019
17083
|
虚假值类型
|
|
17020
17084
|
|
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/core.d.ts
CHANGED
|
@@ -118,6 +118,11 @@ export declare function muid(ctr: sCtr.Ctr, opt?: {
|
|
|
118
118
|
* @param ctr
|
|
119
119
|
*/
|
|
120
120
|
export declare function ip(ctr: sCtr.Ctr | http.IncomingHttpHeaders, req?: http2.Http2ServerRequest | http.IncomingMessage): string;
|
|
121
|
+
/** --- 获取 CF 和 X 的 IP --- */
|
|
122
|
+
export declare function ips(ctr: sCtr.Ctr | http.IncomingHttpHeaders): {
|
|
123
|
+
'cf': string;
|
|
124
|
+
'x': string;
|
|
125
|
+
};
|
|
121
126
|
/** --- 使用 X-Forwarded-For 的 CDN 厂商 --- */
|
|
122
127
|
export declare const REAL_IP_X = "x-forwarded-for";
|
|
123
128
|
/** --- 使用的是 Cloudflare --- */
|
package/lib/core.js
CHANGED
|
@@ -324,6 +324,14 @@ export function ip(ctr, req) {
|
|
|
324
324
|
return req.socket.remoteAddress ?? '';
|
|
325
325
|
}
|
|
326
326
|
}
|
|
327
|
+
/** --- 获取 CF 和 X 的 IP --- */
|
|
328
|
+
export function ips(ctr) {
|
|
329
|
+
const headers = ctr instanceof sCtr.Ctr ? ctr.getPrototype('_headers') : ctr;
|
|
330
|
+
return {
|
|
331
|
+
'cf': typeof headers['cf-connecting-ip'] === 'string' ? headers['cf-connecting-ip'] : '',
|
|
332
|
+
'x': typeof headers['x-forwarded-for'] === 'string' ? headers['x-forwarded-for'] : ''
|
|
333
|
+
};
|
|
334
|
+
}
|
|
327
335
|
/** --- 使用 X-Forwarded-For 的 CDN 厂商 --- */
|
|
328
336
|
export const REAL_IP_X = 'x-forwarded-for';
|
|
329
337
|
/** --- 使用的是 Cloudflare --- */
|
|
@@ -827,7 +835,10 @@ export function log(opt, msg, fend = '') {
|
|
|
827
835
|
}
|
|
828
836
|
hostname = hostname.replace(/:/g, '_');
|
|
829
837
|
const realIp = req?.socket.remoteAddress ?? '';
|
|
830
|
-
const
|
|
838
|
+
const ipss = req ? ips(headers) : {
|
|
839
|
+
'cf': '',
|
|
840
|
+
'x': ''
|
|
841
|
+
};
|
|
831
842
|
const [y, m, d, h] = lTime.format(null, 'Y-m-d-H').split('-');
|
|
832
843
|
let path = kebab.LOG_CWD + hostname + fend + '/' + y + '/' + m + '/' + d + '/';
|
|
833
844
|
const rtn = await lFs.mkdir(path, 0o777);
|
|
@@ -846,7 +857,8 @@ export function log(opt, msg, fend = '') {
|
|
|
846
857
|
'session': session,
|
|
847
858
|
'userAgent': headers['user-agent'] ?? '',
|
|
848
859
|
'realIp': realIp,
|
|
849
|
-
'
|
|
860
|
+
'cfIp': ipss.cf,
|
|
861
|
+
'xIp': ipss.x,
|
|
850
862
|
'osMem': lText.sizeFormat(os.totalmem() - os.freemem(), ''),
|
|
851
863
|
'procMem': lText.sizeFormat(process.memoryUsage().rss, ''),
|
|
852
864
|
'message': msg,
|
|
@@ -861,7 +873,7 @@ export function log(opt, msg, fend = '') {
|
|
|
861
873
|
// --- CSV 格式(默认) ---
|
|
862
874
|
path += h + '.csv';
|
|
863
875
|
if (!await lFs.isFile(path)) {
|
|
864
|
-
if (!await lFs.putContent(path, 'TIME,UNIX,URL,COOKIE,SESSION,USER_AGENT,REALIP,
|
|
876
|
+
if (!await lFs.putContent(path, 'TIME,UNIX,URL,COOKIE,SESSION,USER_AGENT,REALIP,CFIP,XIP,OS,PROCESS,MESSAGE\n', {
|
|
865
877
|
'encoding': 'utf8',
|
|
866
878
|
'mode': 0o777
|
|
867
879
|
})) {
|
|
@@ -869,17 +881,18 @@ export function log(opt, msg, fend = '') {
|
|
|
869
881
|
}
|
|
870
882
|
}
|
|
871
883
|
await lFs.putContent(path, '"' +
|
|
872
|
-
lTime.format(null, 'H:i:s') + '","' +
|
|
873
|
-
lTime.stamp().toString() + '","' +
|
|
874
|
-
urlFull + wpath + (Object.keys(get).length ? '?' + lText.queryStringify(get)
|
|
875
|
-
lText.queryStringify(cookie)
|
|
876
|
-
lText.stringifyJson(session)
|
|
877
|
-
(headers['user-agent']
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
lText.
|
|
881
|
-
lText.sizeFormat(
|
|
882
|
-
|
|
884
|
+
lText.csvescape(lTime.format(null, 'H:i:s')) + '","' +
|
|
885
|
+
lText.csvescape(lTime.stamp().toString()) + '","' +
|
|
886
|
+
lText.csvescape(urlFull + wpath + (Object.keys(get).length ? '?' + lText.queryStringify(get) : '')) + '","' +
|
|
887
|
+
lText.csvescape(lText.queryStringify(cookie)) + '","' +
|
|
888
|
+
lText.csvescape(lText.stringifyJson(session)) + '","' +
|
|
889
|
+
lText.csvescape(headers['user-agent'] ?? 'No HTTP_USER_AGENT') + '","' +
|
|
890
|
+
lText.csvescape(realIp) + '","' +
|
|
891
|
+
lText.csvescape(ipss.cf) + '","' +
|
|
892
|
+
lText.csvescape(ipss.x) + '","' +
|
|
893
|
+
lText.csvescape(lText.sizeFormat(os.totalmem() - os.freemem(), '')) + '","' +
|
|
894
|
+
lText.csvescape(lText.sizeFormat(process.memoryUsage().rss, '')) + '","' +
|
|
895
|
+
lText.csvescape(msg) + '"\n', {
|
|
883
896
|
'encoding': 'utf8',
|
|
884
897
|
'mode': 0o777,
|
|
885
898
|
'flag': 'a'
|
package/lib/text.d.ts
CHANGED
|
@@ -128,6 +128,8 @@ export declare function queryParse(query: string): Record<string, string | strin
|
|
|
128
128
|
* @param html 待转换的 HTML
|
|
129
129
|
*/
|
|
130
130
|
export declare function htmlescape(html: string): string;
|
|
131
|
+
/** --- CSV 特殊字符转换为实体字符 --- */
|
|
132
|
+
export declare function csvescape(str: string): string;
|
|
131
133
|
/**
|
|
132
134
|
* --- 判断是否是绝对路径,是返回 true,相对路径返回 false ---
|
|
133
135
|
* @param path 要判断的路径字符串
|
package/lib/text.js
CHANGED
|
@@ -431,6 +431,10 @@ export function htmlescape(html) {
|
|
|
431
431
|
}
|
|
432
432
|
return html.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/'/g, '"');
|
|
433
433
|
}
|
|
434
|
+
/** --- CSV 特殊字符转换为实体字符 --- */
|
|
435
|
+
export function csvescape(str) {
|
|
436
|
+
return String(str ?? '').replace(/"/g, '""');
|
|
437
|
+
}
|
|
434
438
|
/**
|
|
435
439
|
* --- 判断是否是绝对路径,是返回 true,相对路径返回 false ---
|
|
436
440
|
* @param path 要判断的路径字符串
|
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
|
}
|