chore(run/core): 🔧 Optimize parallel deployment execution in orchestration logic

Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
Quinn Ftw 2026-02-02 15:39:14 -08:00
parent 872cac5e0e
commit eee72a9e71

View file

@ -611,12 +611,16 @@ export class DeploymentOrchestrator {
* 3. Log results and continue even if cleanup fails
*/
private async cleanupOrphanedPorts(deploymentOrder: string[]): Promise<void> {
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;
}