MCPcopy
hub / github.com/subquery/subql / findAvailablePort

Function findAvailablePort

packages/utils/src/networking.ts:6–19  ·  view source on GitHub ↗
(startPort: number, range = 10)

Source from the content-addressed store, hash-verified

4import detectPort from 'detect-port';
5
6export async function findAvailablePort(startPort: number, range = 10): Promise<number | null> {
7 for (let port = startPort; port <= startPort + range; port++) {
8 try {
9 const _port = await detectPort(port);
10 if (_port === port) {
11 return port;
12 }
13 } catch (e) {
14 return null;
15 }
16 }
17
18 return null;
19}

Callers 2

getValidPortFunction · 0.90
main.tsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected