fix(processmanager): Improve process lifecycle handling and cleanup in daemon, monitors and wrappers

This commit is contained in:
2025-08-31 07:45:47 +00:00
parent 8f31672a67
commit 0a75c4cf76
6 changed files with 56 additions and 32 deletions

View File

@@ -450,10 +450,12 @@ export class TspmDaemon {
await this.tspmInstance.setDesiredStateForAll('stopped');
await this.tspmInstance.stopAll();
// Yield briefly to allow any pending exit events to settle
await new Promise((r) => setTimeout(r, 50));
// Get status of all processes
for (const [id, processInfo] of this.tspmInstance.processInfo) {
if (processInfo.status === 'stopped') {
// Determine which monitors are no longer running
for (const [id, monitor] of this.tspmInstance.processes) {
if (!monitor.isRunning()) {
stopped.push(id);
} else {
failed.push({ id, error: 'Failed to stop' });