tycono 0.3.13-beta.0 → 0.3.13-beta.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/bin/cli.js +1 -0
- package/bin/tycono.ts +29 -3
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -11,6 +11,7 @@ if (!process.env.__TYCONO_HEAP_SET && !process.execArgv.some(a => a.includes('ma
|
|
|
11
11
|
try {
|
|
12
12
|
execFileSync(process.execPath, [
|
|
13
13
|
'--max-old-space-size=8192',
|
|
14
|
+
'--expose-gc',
|
|
14
15
|
...process.execArgv,
|
|
15
16
|
fileURLToPath(import.meta.url),
|
|
16
17
|
...process.argv.slice(2),
|
package/bin/tycono.ts
CHANGED
|
@@ -270,11 +270,37 @@ async function startServerForTui(): Promise<void> {
|
|
|
270
270
|
origLog(` API server started on port ${port}`);
|
|
271
271
|
origLog(` Logs: ${logFile}`);
|
|
272
272
|
|
|
273
|
-
// Memory monitor —
|
|
273
|
+
// Memory monitor — 10s interval, with spike detection + forced GC
|
|
274
|
+
let lastHeap = 0;
|
|
274
275
|
setInterval(() => {
|
|
275
276
|
const mem = process.memoryUsage();
|
|
276
|
-
|
|
277
|
-
|
|
277
|
+
const heapMB = Math.round(mem.heapUsed / 1024 / 1024);
|
|
278
|
+
const heapTotalMB = Math.round(mem.heapTotal / 1024 / 1024);
|
|
279
|
+
const rssMB = Math.round(mem.rss / 1024 / 1024);
|
|
280
|
+
const spike = heapMB - lastHeap;
|
|
281
|
+
|
|
282
|
+
// Always log
|
|
283
|
+
logStream.write(`[MEM] heap=${heapMB}MB/${heapTotalMB}MB rss=${rssMB}MB${spike > 50 ? ` ⚠️ SPIKE +${spike}MB` : ''}\n`);
|
|
284
|
+
|
|
285
|
+
// Spike detection: >100MB jump in 10s
|
|
286
|
+
if (spike > 100) {
|
|
287
|
+
logStream.write(`[MEM] ⛔ MEMORY SPIKE: +${spike}MB in 10s (${lastHeap}MB → ${heapMB}MB)\n`);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
// Warning at 2GB
|
|
291
|
+
if (heapMB > 2048 && lastHeap <= 2048) {
|
|
292
|
+
logStream.write(`[MEM] ⚠️ HEAP WARNING: ${heapMB}MB — approaching limit. Forcing GC.\n`);
|
|
293
|
+
if (global.gc) global.gc();
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
// Critical at 4GB — force GC
|
|
297
|
+
if (heapMB > 4096) {
|
|
298
|
+
logStream.write(`[MEM] ⛔ HEAP CRITICAL: ${heapMB}MB — forcing GC\n`);
|
|
299
|
+
if (global.gc) global.gc();
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
lastHeap = heapMB;
|
|
303
|
+
}, 10_000).unref();
|
|
278
304
|
|
|
279
305
|
// Graceful shutdown — mark active sessions as interrupted
|
|
280
306
|
const shutdown = () => {
|