livedesk 0.1.258 → 0.1.260
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/bin/livedesk.js
CHANGED
|
@@ -239,26 +239,26 @@ function probePortBind(port, host = '0.0.0.0') {
|
|
|
239
239
|
});
|
|
240
240
|
}
|
|
241
241
|
|
|
242
|
-
async function canBindPort(port, host = '0.0.0.0') {
|
|
243
|
-
return (await probePortBind(port, host)).ok;
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
async function waitForPortBindable(port, host = '0.0.0.0', timeoutMs = PORT_CLEANUP_TIMEOUT_MS) {
|
|
247
|
-
const deadline = Date.now() + timeoutMs;
|
|
248
|
-
let lastProbe = { ok: false, error: 'bind-not-tested' };
|
|
249
|
-
do {
|
|
250
|
-
lastProbe = await probePortBind(port, host);
|
|
251
|
-
if (lastProbe.ok) {
|
|
252
|
-
return lastProbe;
|
|
253
|
-
}
|
|
254
|
-
const remainingMs = deadline - Date.now();
|
|
255
|
-
if (remainingMs <= 0) {
|
|
256
|
-
break;
|
|
257
|
-
}
|
|
258
|
-
await waitMilliseconds(Math.min(PORT_CLEANUP_POLL_MS, remainingMs));
|
|
259
|
-
} while (true);
|
|
260
|
-
return lastProbe;
|
|
261
|
-
}
|
|
242
|
+
async function canBindPort(port, host = '0.0.0.0') {
|
|
243
|
+
return (await probePortBind(port, host)).ok;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
async function waitForPortBindable(port, host = '0.0.0.0', timeoutMs = PORT_CLEANUP_TIMEOUT_MS) {
|
|
247
|
+
const deadline = Date.now() + timeoutMs;
|
|
248
|
+
let lastProbe = { ok: false, error: 'bind-not-tested' };
|
|
249
|
+
do {
|
|
250
|
+
lastProbe = await probePortBind(port, host);
|
|
251
|
+
if (lastProbe.ok) {
|
|
252
|
+
return lastProbe;
|
|
253
|
+
}
|
|
254
|
+
const remainingMs = deadline - Date.now();
|
|
255
|
+
if (remainingMs <= 0) {
|
|
256
|
+
break;
|
|
257
|
+
}
|
|
258
|
+
await waitMilliseconds(Math.min(PORT_CLEANUP_POLL_MS, remainingMs));
|
|
259
|
+
} while (true);
|
|
260
|
+
return lastProbe;
|
|
261
|
+
}
|
|
262
262
|
|
|
263
263
|
function isKnownLiveDeskProcess(processName, commandLine) {
|
|
264
264
|
const normalizedName = String(processName || '').trim();
|
|
@@ -452,10 +452,10 @@ async function stopProcessesOnPorts(ports) {
|
|
|
452
452
|
const rawStatesByPort = new Map(rawPortStates.map(state => [Number(state?.Port), state]));
|
|
453
453
|
const portStates = [];
|
|
454
454
|
for (const port of uniquePorts) {
|
|
455
|
-
const rawState = rawStatesByPort.get(Number(port)) || {};
|
|
456
|
-
const probe = rawState.PortAvailable === true
|
|
457
|
-
? await waitForPortBindable(port)
|
|
458
|
-
: { ok: false, error: 'port-in-use' };
|
|
455
|
+
const rawState = rawStatesByPort.get(Number(port)) || {};
|
|
456
|
+
const probe = rawState.PortAvailable === true
|
|
457
|
+
? await waitForPortBindable(port)
|
|
458
|
+
: { ok: false, error: 'port-in-use' };
|
|
459
459
|
portStates.push({
|
|
460
460
|
...rawState,
|
|
461
461
|
Port: Number(port),
|