@maiyunnet/kebab 9.15.5 → 9.16.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 +194 -104
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/lib/core.d.ts +27 -3
- package/lib/core.js +32 -4
- 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 +1 -1
- package/lib/undici/response.js +2 -1
- package/lib/undici.d.ts +7 -3
- package/lib/undici.js +48 -8
- package/package.json +1 -1
- package/sys/child.js +15 -12
- package/sys/ctr.js +3 -3
- package/sys/master.js +41 -2
- 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/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('');
|