INNER CODE UNIT · JavaScript
handlePortConflict
aeonfun/opendia · opendia-mcp/server.js:149
async function handlePortConflict(port, portName) {
const isInUse = await checkPortInUse(port);
if (!isInUse) {
return port; // Port is free, use it
}
// Port is busy - give user options
console.error(`⚠️ ${portName} port ${port} is already in use`);
// Check if it's likely another OpenDia instance
const isOpenDia = await checkIfOpenDiaProcess(port);
if (isOpenDia) {
console.error(`🔍 Detected existing OpenDia instance on port ${port} (this should not happen after cleanup)`);
console.error(`⚠️ Attempting to kill remaining process...`);
await killExistingOpenDia(port);
await new Promise(resolve => setTimeout(resolve, 1000));