( engine: ExecutionEngine, showTop: boolean )
| 1007 | } |
| 1008 | |
| 1009 | async function startMetricsMonitoring( |
| 1010 | engine: ExecutionEngine, |
| 1011 | showTop: boolean |
| 1012 | ): Promise<ReturnType<typeof setInterval> | null> { |
| 1013 | if (!showTop || !engine.serverPort) { |
| 1014 | return null |
| 1015 | } |
| 1016 | |
| 1017 | const port = engine.serverPort |
| 1018 | const initialMetrics = await fetchMetrics(port) |
| 1019 | if (initialMetrics) { |
| 1020 | displayMetrics(initialMetrics) |
| 1021 | output('') |
| 1022 | } |
| 1023 | |
| 1024 | return setInterval(async () => { |
| 1025 | const metrics = await fetchMetrics(port) |
| 1026 | if (metrics) { |
| 1027 | // Move cursor up, clear line, display metrics, move back down |
| 1028 | process.stdout.write('\x1b[s') // Save cursor position |
| 1029 | displayMetrics(metrics) |
| 1030 | process.stdout.write('\x1b[u') // Restore cursor position |
| 1031 | } |
| 1032 | }, 2000) |
| 1033 | } |
| 1034 | |
| 1035 | function createRunProjectCallbacks({ |
| 1036 | engine, |
no test coverage detected