feat(cli): Add stats CLI command and daemon stats aggregation; fix process manager & wrapper state handling

This commit is contained in:
2025-08-31 08:06:03 +00:00
parent 1c4ffbb612
commit 6f14033d9b
9 changed files with 166 additions and 7 deletions

View File

@@ -93,6 +93,9 @@ export class ProcessWrapper extends EventEmitter {
this.stdoutRemainder = '';
this.stderrRemainder = '';
// Mark process reference as gone so isRunning() reflects reality
this.process = null;
this.emit('exit', code, signal);
});
@@ -269,6 +272,7 @@ export class ProcessWrapper extends EventEmitter {
* Get the process ID if running
*/
public getPid(): number | null {
if (!this.isRunning()) return null;
return this.process?.pid || null;
}
@@ -292,7 +296,13 @@ export class ProcessWrapper extends EventEmitter {
* Check if the process is currently running
*/
public isRunning(): boolean {
return this.process !== null && typeof this.process.exitCode !== 'number';
if (!this.process) return false;
// In Node, while the child is running: exitCode === null and signalCode === null/undefined
// After it exits: exitCode is a number OR signalCode is a string
const anyProc: any = this.process as any;
const exitCode = anyProc.exitCode;
const signalCode = anyProc.signalCode;
return exitCode === null && (signalCode === null || typeof signalCode === 'undefined');
}
/**