diff --git a/run/core/deployment-orchestrator.ts b/run/core/deployment-orchestrator.ts index 9354bcd..5153bf8 100644 --- a/run/core/deployment-orchestrator.ts +++ b/run/core/deployment-orchestrator.ts @@ -611,12 +611,16 @@ export class DeploymentOrchestrator { * 3. Log results and continue even if cleanup fails */ private async cleanupOrphanedPorts(deploymentOrder: string[]): Promise { + this.logger.info(`Checking ${deploymentOrder.length} deployments for orphaned ports...`); const orphanedPorts: Array<{ port: number; pid: number; serviceId: string }> = []; // Phase 1: Discover all orphaned ports for (const depName of deploymentOrder) { const depManifest = this.deploymentRegistry.get(depName); - if (!depManifest) continue; + if (!depManifest) { + this.logger.debug(`[OrphanCleanup] Deployment '${depName}' not found in registry`); + continue; + } for (const svc of depManifest.services) { if (DOCKER_ONLY_TYPES.has(svc.type)) continue; @@ -626,17 +630,22 @@ export class DeploymentOrchestrator { // If we already have a PID file, normal shutdown handled it const trackedPid = await readPidFile(serviceId); - if (trackedPid !== null) continue; + if (trackedPid !== null) { + this.logger.debug(`[OrphanCleanup] ${serviceId} has PID file (${trackedPid}), skipping`); + continue; + } // Check if an orphaned process is holding this port const portPid = await getPortPid(svc.port); if (portPid) { + this.logger.info(` → Port ${svc.port} (${serviceId}) held by orphan PID ${portPid}`); orphanedPorts.push({ port: svc.port, pid: portPid, serviceId }); } } } if (orphanedPorts.length === 0) { + this.logger.debug('[OrphanCleanup] No orphaned processes found'); return; }