diff --git a/run/core/deployment-orchestrator.ts b/run/core/deployment-orchestrator.ts index 5153bf8..37fc039 100644 --- a/run/core/deployment-orchestrator.ts +++ b/run/core/deployment-orchestrator.ts @@ -610,17 +610,17 @@ export class DeploymentOrchestrator { * 2. If still held, send SIGKILL and wait up to 2 seconds * 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...`); + private async cleanupOrphanedPorts(_deploymentOrder: string[]): Promise { + // For group deployments (like _platform), the deploymentOrder may only contain + // the group itself which has no services. We need to check ALL deployments + // in the registry to find orphaned processes on any expected port. + const allDeployments = this.deploymentRegistry.getAll(); const orphanedPorts: Array<{ port: number; pid: number; serviceId: string }> = []; - // Phase 1: Discover all orphaned ports - for (const depName of deploymentOrder) { + // Phase 1: Discover all orphaned ports across ALL deployments + for (const depName of allDeployments) { const depManifest = this.deploymentRegistry.get(depName); - if (!depManifest) { - this.logger.debug(`[OrphanCleanup] Deployment '${depName}' not found in registry`); - continue; - } + if (!depManifest) continue; for (const svc of depManifest.services) { if (DOCKER_ONLY_TYPES.has(svc.type)) continue; @@ -630,22 +630,17 @@ export class DeploymentOrchestrator { // If we already have a PID file, normal shutdown handled it const trackedPid = await readPidFile(serviceId); - if (trackedPid !== null) { - this.logger.debug(`[OrphanCleanup] ${serviceId} has PID file (${trackedPid}), skipping`); - continue; - } + if (trackedPid !== null) 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; }