feat(cli): Add stats CLI command and daemon stats aggregation; fix process manager & wrapper state handling
This commit is contained in:
@@ -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');
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user