bgrun 3.12.14 → 3.12.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +14 -25
- package/dist/server.js +14 -25
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1321,33 +1321,22 @@ async function cleanupPort(port) {
|
|
|
1321
1321
|
if (process.platform !== "win32")
|
|
1322
1322
|
return port;
|
|
1323
1323
|
try {
|
|
1324
|
-
const
|
|
1325
|
-
|
|
1326
|
-
"-NoProfile",
|
|
1327
|
-
"-Command",
|
|
1328
|
-
`Get-NetTCPConnection -LocalPort ${port} -State Listen -ErrorAction SilentlyContinue | Select-Object -ExpandProperty OwningProcess`
|
|
1329
|
-
], { stdout: "pipe", stderr: "pipe" });
|
|
1330
|
-
const text = await new Response(proc.stdout).text();
|
|
1331
|
-
const pid = parseInt(text.trim(), 10);
|
|
1332
|
-
if (!pid || pid === process.pid)
|
|
1324
|
+
const occupiedBefore = !await isPortFree(port);
|
|
1325
|
+
if (!occupiedBefore)
|
|
1333
1326
|
return port;
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
`Get-Process -Id ${pid} -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Id`
|
|
1339
|
-
], { stdout: "pipe", stderr: "pipe" });
|
|
1340
|
-
const checkText = await new Response(checkProc.stdout).text();
|
|
1341
|
-
if (checkText.trim()) {
|
|
1342
|
-
console.log(`[server] Killing PID ${pid} holding port ${port}`);
|
|
1343
|
-
Bun.spawn(["taskkill", "/F", "/PID", String(pid)], { stdout: "pipe", stderr: "pipe" });
|
|
1344
|
-
await Bun.sleep(1000);
|
|
1327
|
+
console.log(`[server] Reclaiming port ${port} before dashboard start`);
|
|
1328
|
+
await killProcessOnPort(port);
|
|
1329
|
+
const freed = await waitForPortFree(port, 8000);
|
|
1330
|
+
if (freed)
|
|
1345
1331
|
return port;
|
|
1346
|
-
}
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1332
|
+
console.warn(`[server] Port ${port} still busy after first cleanup; retrying`);
|
|
1333
|
+
await killProcessOnPort(port);
|
|
1334
|
+
const freedAfterRetry = await waitForPortFree(port, 5000);
|
|
1335
|
+
if (freedAfterRetry)
|
|
1336
|
+
return port;
|
|
1337
|
+
const fallback = port + 1;
|
|
1338
|
+
console.warn(`[server] \u26A0 Could not reclaim port ${port}; falling back to port ${fallback}`);
|
|
1339
|
+
return fallback;
|
|
1351
1340
|
} catch {
|
|
1352
1341
|
return port;
|
|
1353
1342
|
}
|
package/dist/server.js
CHANGED
|
@@ -1320,33 +1320,22 @@ async function cleanupPort(port) {
|
|
|
1320
1320
|
if (process.platform !== "win32")
|
|
1321
1321
|
return port;
|
|
1322
1322
|
try {
|
|
1323
|
-
const
|
|
1324
|
-
|
|
1325
|
-
"-NoProfile",
|
|
1326
|
-
"-Command",
|
|
1327
|
-
`Get-NetTCPConnection -LocalPort ${port} -State Listen -ErrorAction SilentlyContinue | Select-Object -ExpandProperty OwningProcess`
|
|
1328
|
-
], { stdout: "pipe", stderr: "pipe" });
|
|
1329
|
-
const text = await new Response(proc.stdout).text();
|
|
1330
|
-
const pid = parseInt(text.trim(), 10);
|
|
1331
|
-
if (!pid || pid === process.pid)
|
|
1323
|
+
const occupiedBefore = !await isPortFree(port);
|
|
1324
|
+
if (!occupiedBefore)
|
|
1332
1325
|
return port;
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
`Get-Process -Id ${pid} -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Id`
|
|
1338
|
-
], { stdout: "pipe", stderr: "pipe" });
|
|
1339
|
-
const checkText = await new Response(checkProc.stdout).text();
|
|
1340
|
-
if (checkText.trim()) {
|
|
1341
|
-
console.log(`[server] Killing PID ${pid} holding port ${port}`);
|
|
1342
|
-
Bun.spawn(["taskkill", "/F", "/PID", String(pid)], { stdout: "pipe", stderr: "pipe" });
|
|
1343
|
-
await Bun.sleep(1000);
|
|
1326
|
+
console.log(`[server] Reclaiming port ${port} before dashboard start`);
|
|
1327
|
+
await killProcessOnPort(port);
|
|
1328
|
+
const freed = await waitForPortFree(port, 8000);
|
|
1329
|
+
if (freed)
|
|
1344
1330
|
return port;
|
|
1345
|
-
}
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1331
|
+
console.warn(`[server] Port ${port} still busy after first cleanup; retrying`);
|
|
1332
|
+
await killProcessOnPort(port);
|
|
1333
|
+
const freedAfterRetry = await waitForPortFree(port, 5000);
|
|
1334
|
+
if (freedAfterRetry)
|
|
1335
|
+
return port;
|
|
1336
|
+
const fallback = port + 1;
|
|
1337
|
+
console.warn(`[server] \u26A0 Could not reclaim port ${port}; falling back to port ${fallback}`);
|
|
1338
|
+
return fallback;
|
|
1350
1339
|
} catch {
|
|
1351
1340
|
return port;
|
|
1352
1341
|
}
|