@maiyunnet/kebab 9.15.6 → 9.16.1
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 +216 -121
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/lib/core.d.ts +22 -3
- package/lib/core.js +23 -4
- package/lib/db/conn.js +13 -3
- package/lib/db/pool.js +21 -11
- package/lib/text.d.ts +6 -0
- package/lib/text.js +24 -1
- package/lib/undici/request.d.ts +6 -1
- package/lib/undici/request.js +8 -0
- package/lib/undici/response.d.ts +2 -2
- package/lib/undici/response.js +2 -1
- package/lib/undici.d.ts +13 -6
- package/lib/undici.js +83 -35
- package/package.json +1 -1
- package/sys/child.js +15 -12
- package/sys/ctr.js +3 -3
- package/sys/monitor/watchdog.js +9 -5
- package/sys/monitor.d.ts +8 -1
- package/sys/monitor.js +198 -81
- package/sys/route.d.ts +1 -1
- package/sys/route.js +14 -14
- package/www/example/ctr/test.d.ts +2 -0
- package/www/example/ctr/test.js +44 -3
package/sys/route.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Project: Kebab, User: JianSuoQiYue
|
|
3
3
|
* Date: 2019-4-15 13:40
|
|
4
|
-
* Last: 2020-4-14 13:52:00, 2022-09-07 01:43:31, 2023-12-29 17:24:03, 2024-2-7 00:28:50, 2024-6-6 15:15:54, 2025-6-13 19:23:53, 2025-9-22 15:48:53, 2025-9-23 11:26:50, 2025-10-30 17:44:41
|
|
4
|
+
* Last: 2020-4-14 13:52:00, 2022-09-07 01:43:31, 2023-12-29 17:24:03, 2024-2-7 00:28:50, 2024-6-6 15:15:54, 2025-6-13 19:23:53, 2025-9-22 15:48:53, 2025-9-23 11:26:50, 2025-10-30 17:44:41, 2026-8-22
|
|
5
5
|
*/
|
|
6
6
|
import * as http from 'http';
|
|
7
7
|
import * as stream from 'stream';
|
|
@@ -300,7 +300,7 @@ export async function run(data) {
|
|
|
300
300
|
cctr.setPrototype('_socket', wsSocket);
|
|
301
301
|
}
|
|
302
302
|
catch (e) {
|
|
303
|
-
lCore.log(cctr, lText.
|
|
303
|
+
lCore.log(cctr, lText.stringifyError(e), '-error');
|
|
304
304
|
data.socket?.destroy();
|
|
305
305
|
return true;
|
|
306
306
|
}
|
|
@@ -314,7 +314,7 @@ export async function run(data) {
|
|
|
314
314
|
rtn = await cctr.onLoad();
|
|
315
315
|
}
|
|
316
316
|
catch (e) {
|
|
317
|
-
lCore.log(cctr, lText.
|
|
317
|
+
lCore.log(cctr, lText.stringifyError(e), '-error');
|
|
318
318
|
data.socket?.destroy();
|
|
319
319
|
return true;
|
|
320
320
|
}
|
|
@@ -323,7 +323,7 @@ export async function run(data) {
|
|
|
323
323
|
rtn = await cctr.onReady();
|
|
324
324
|
}
|
|
325
325
|
catch (e) {
|
|
326
|
-
lCore.log(cctr, lText.
|
|
326
|
+
lCore.log(cctr, lText.stringifyError(e), '-error');
|
|
327
327
|
data.socket?.destroy();
|
|
328
328
|
return true;
|
|
329
329
|
}
|
|
@@ -380,7 +380,7 @@ export async function run(data) {
|
|
|
380
380
|
}
|
|
381
381
|
}
|
|
382
382
|
catch (e) {
|
|
383
|
-
lCore.log(cctr, lText.
|
|
383
|
+
lCore.log(cctr, lText.stringifyError(e), '-error');
|
|
384
384
|
}
|
|
385
385
|
break;
|
|
386
386
|
}
|
|
@@ -393,23 +393,23 @@ export async function run(data) {
|
|
|
393
393
|
await cctr['onDrain']();
|
|
394
394
|
}
|
|
395
395
|
catch (e) {
|
|
396
|
-
lCore.log(cctr, lText.
|
|
396
|
+
lCore.log(cctr, lText.stringifyError(e), '-error');
|
|
397
397
|
}
|
|
398
398
|
}).on('error', (e) => {
|
|
399
|
-
lCore.log(cctr, lText.
|
|
399
|
+
lCore.log(cctr, lText.stringifyError(e), '-error');
|
|
400
400
|
}).on('end', async () => {
|
|
401
401
|
try {
|
|
402
402
|
await cctr['onEnd']();
|
|
403
403
|
}
|
|
404
404
|
catch (e) {
|
|
405
|
-
lCore.log(cctr, lText.
|
|
405
|
+
lCore.log(cctr, lText.stringifyError(e), '-error');
|
|
406
406
|
}
|
|
407
407
|
}).on('close', async () => {
|
|
408
408
|
try {
|
|
409
409
|
await cctr['onClose']();
|
|
410
410
|
}
|
|
411
411
|
catch (e) {
|
|
412
|
-
lCore.log(cctr, lText.
|
|
412
|
+
lCore.log(cctr, lText.stringifyError(e), '-error');
|
|
413
413
|
}
|
|
414
414
|
resolve();
|
|
415
415
|
});
|
|
@@ -467,7 +467,7 @@ export async function run(data) {
|
|
|
467
467
|
rtn = await middle.onLoad();
|
|
468
468
|
}
|
|
469
469
|
catch (e) {
|
|
470
|
-
lCore.log(middle, '(E03)' + lText.
|
|
470
|
+
lCore.log(middle, '(E03)' + lText.stringifyError(e), '-error');
|
|
471
471
|
respond500(data.res);
|
|
472
472
|
return true;
|
|
473
473
|
}
|
|
@@ -479,7 +479,7 @@ export async function run(data) {
|
|
|
479
479
|
rtn = await middle.onReady();
|
|
480
480
|
}
|
|
481
481
|
catch (e) {
|
|
482
|
-
lCore.log(middle, '(E05)' + lText.
|
|
482
|
+
lCore.log(middle, '(E05)' + lText.stringifyError(e), '-error');
|
|
483
483
|
respond500(data.res);
|
|
484
484
|
return true;
|
|
485
485
|
}
|
|
@@ -556,7 +556,7 @@ export async function run(data) {
|
|
|
556
556
|
}
|
|
557
557
|
}
|
|
558
558
|
catch (e) {
|
|
559
|
-
lCore.log(cctr, '(E05)' + lText.
|
|
559
|
+
lCore.log(cctr, '(E05)' + lText.stringifyError(e), '-error');
|
|
560
560
|
respond500(data.res);
|
|
561
561
|
await waitCtr(cctr);
|
|
562
562
|
return true;
|
|
@@ -567,7 +567,7 @@ export async function run(data) {
|
|
|
567
567
|
httpCode = cctr.getPrototype('_httpCode');
|
|
568
568
|
}
|
|
569
569
|
catch (e) {
|
|
570
|
-
lCore.log(cctr, '(E04)' + lText.
|
|
570
|
+
lCore.log(cctr, '(E04)' + lText.stringifyError(e), '-error');
|
|
571
571
|
respond500(data.res);
|
|
572
572
|
await waitCtr(cctr);
|
|
573
573
|
return true;
|
|
@@ -1291,7 +1291,7 @@ export function getFormData(req, events = {}, limits = {}) {
|
|
|
1291
1291
|
clearTimer();
|
|
1292
1292
|
cleanupActiveFile();
|
|
1293
1293
|
lCore.debug('[ROUTE][GETFORMDATA] request error before getFormData: ' + e.message);
|
|
1294
|
-
lCore.log({}, '[ROUTE][GETFORMDATA] request error before getFormData: ' + (e
|
|
1294
|
+
lCore.log({}, '[ROUTE][GETFORMDATA] request error before getFormData: ' + lText.stringifyError(e), '-error');
|
|
1295
1295
|
cleanupFiles();
|
|
1296
1296
|
resolve(false);
|
|
1297
1297
|
});
|
|
@@ -87,6 +87,8 @@ export default class extends sCtr.Ctr {
|
|
|
87
87
|
undiciFollow2(): kebab.Json;
|
|
88
88
|
undiciReuse(): Promise<string>;
|
|
89
89
|
undiciError(): Promise<string>;
|
|
90
|
+
undiciRetry(): Promise<string>;
|
|
91
|
+
undiciRetrySource(): Promise<string | boolean>;
|
|
90
92
|
undiciHosts(): Promise<string>;
|
|
91
93
|
undiciMproxy(): Promise<string | boolean>;
|
|
92
94
|
undiciMproxy1(): Promise<string | boolean>;
|
package/www/example/ctr/test.js
CHANGED
|
@@ -186,6 +186,7 @@ export default class extends sCtr.Ctr {
|
|
|
186
186
|
`<br><a href="${this._config.const.urlBase}test/undici-follow">View "test/undici-follow"</a>`,
|
|
187
187
|
`<br><a href="${this._config.const.urlBase}test/undici-reuse">View "test/undici-reuse"</a>`,
|
|
188
188
|
`<br><a href="${this._config.const.urlBase}test/undici-error">View "test/undici-error"</a>`,
|
|
189
|
+
`<br><a href="${this._config.const.urlBase}test/undici-retry">View "test/undici-retry"</a>`,
|
|
189
190
|
`<br><a href="${this._config.const.urlBase}test/undici-hosts">View "test/undici-hosts"</a>`,
|
|
190
191
|
`<br><a href="${this._config.const.urlBase}test/undici-rproxy/dist/core.js">View "test/undici-rproxy/dist/core.js"</a> <a href="${this._config.const.urlBase}test/undici-rproxy/package.json">View "package.json"</a>`,
|
|
191
192
|
`<br><a href="${this._config.const.urlBase}test/undici-mproxy">View "test/undici-mproxy"</a>`,
|
|
@@ -2212,6 +2213,46 @@ content: <pre>${(await res.getContent())?.toString() ?? 'null'}</pre>
|
|
|
2212
2213
|
error: <pre>${JSON.stringify(res.error, null, 4)}</pre>`);
|
|
2213
2214
|
return echo.join('') + this._getEnd();
|
|
2214
2215
|
}
|
|
2216
|
+
async undiciRetry() {
|
|
2217
|
+
const url = `${this._internalUrl}test/undici-retry-source`;
|
|
2218
|
+
const time = Date.now();
|
|
2219
|
+
const res = await lUndici.get(url, {
|
|
2220
|
+
'retry': 1,
|
|
2221
|
+
'log': false,
|
|
2222
|
+
});
|
|
2223
|
+
const content = await res.getContent();
|
|
2224
|
+
return `<pre>const res = await lUndici.get('${url}', {
|
|
2225
|
+
'retry': 1,
|
|
2226
|
+
'log': false,
|
|
2227
|
+
});
|
|
2228
|
+
const content = await res.getContent();</pre>
|
|
2229
|
+
time: ${Date.now() - time}ms
|
|
2230
|
+
headers: <pre>${lText.htmlescape(lText.stringifyJson(res.headers))}</pre>
|
|
2231
|
+
content: <pre>${lText.htmlescape(content?.toString() ?? 'null')}</pre>
|
|
2232
|
+
error: <pre>${lText.htmlescape(res.error ? lText.stringifyError(res.error) : 'null')}</pre>` + this._getEnd();
|
|
2233
|
+
}
|
|
2234
|
+
async undiciRetrySource() {
|
|
2235
|
+
const etag = '"undici-retry"';
|
|
2236
|
+
if ((this._headers['range'] === 'bytes=1-1') && (this._headers['if-match'] === etag)) {
|
|
2237
|
+
this._httpCode = 206;
|
|
2238
|
+
this._res.setHeader('content-length', '1');
|
|
2239
|
+
this._res.setHeader('content-range', 'bytes 1-1/2');
|
|
2240
|
+
this._res.setHeader('etag', etag);
|
|
2241
|
+
return 'K';
|
|
2242
|
+
}
|
|
2243
|
+
lCore.writeHead(this._res, 200, {
|
|
2244
|
+
'content-length': '2',
|
|
2245
|
+
etag,
|
|
2246
|
+
});
|
|
2247
|
+
lCore.write(this._res, 'O');
|
|
2248
|
+
await new Promise(resolve => {
|
|
2249
|
+
setImmediate(() => {
|
|
2250
|
+
this._res.destroy();
|
|
2251
|
+
resolve();
|
|
2252
|
+
});
|
|
2253
|
+
});
|
|
2254
|
+
return false;
|
|
2255
|
+
}
|
|
2215
2256
|
async undiciHosts() {
|
|
2216
2257
|
const echo = [];
|
|
2217
2258
|
const res = await lUndici.get('http://nodejs.org:' + this._config.const.hostport.toString() + this._config.const.urlBase + 'test', {
|
|
@@ -4083,7 +4124,7 @@ send.addEventListener('click', async () => {
|
|
|
4083
4124
|
'<b>Monitor Snapshot</b>',
|
|
4084
4125
|
'<hr>',
|
|
4085
4126
|
`<b>PID:</b> ${snapshot.pid}`,
|
|
4086
|
-
`<br><b>Process CPU (
|
|
4127
|
+
`<br><b>Process CPU (100% per core):</b> ${snapshot.cpuProcess}%`,
|
|
4087
4128
|
`<br><b>System CPU (total):</b> ${snapshot.cpuOs}%`,
|
|
4088
4129
|
`<br><b>Event Loop Lag:</b> ${snapshot.eloopLag}ms`,
|
|
4089
4130
|
'<br><br><b>Memory:</b>',
|
|
@@ -4102,7 +4143,7 @@ send.addEventListener('click', async () => {
|
|
|
4102
4143
|
`<br><br><b>Active Requests:</b> ${snapshot.activeCount}`,
|
|
4103
4144
|
];
|
|
4104
4145
|
for (const req of snapshot.activeRequests) {
|
|
4105
|
-
echo.push(`<br>[${req.method}] ${lText.htmlescape(req.url)} - ${req.duration}ms,
|
|
4146
|
+
echo.push(`<br>[${req.method}] ${lText.htmlescape(req.url)} - ${req.duration}ms, PROCESS_CPU_DELTA: ${req.cpuUser + req.cpuSystem}us, PROCESS_MEM_DELTA: ${lText.sizeFormat(req.memDelta)}`);
|
|
4106
4147
|
}
|
|
4107
4148
|
echo.push('<br><br>' + this._getEnd());
|
|
4108
4149
|
return echo.join('');
|
|
@@ -4156,7 +4197,7 @@ send.addEventListener('click', async () => {
|
|
|
4156
4197
|
`System CPU ${after.cpuOs}%, ` +
|
|
4157
4198
|
`RSS ${lText.sizeFormat(after.mem.rss)}, ` +
|
|
4158
4199
|
`Iterations: ${count}`);
|
|
4159
|
-
echo.push('<br><br>Check <code>log/monitor/{pid}/</code> for' +
|
|
4200
|
+
echo.push('<br><br>Check <code>log/monitor/YYYY/MM/DD/HHmmss-pid-{pid}/</code> for' +
|
|
4160
4201
|
' diagnostic files.');
|
|
4161
4202
|
echo.push('<br><br>' + this._getEnd());
|
|
4162
4203
|
return echo.join('');
|