How to use the portscanner.findAPortNotInUseAsync function in portscanner

To help you get started, we’ve selected a few portscanner examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kengz / aiva / src / env.js View on Github external
function setPort(env) {
  var basePort = config.get(`PORTS.${env['ADAPTER']}`)
  return portscanner.findAPortNotInUseAsync(basePort, basePort + 50, '127.0.0.1')
    .then((port) => {
      env['PORT'] = port
      log.debug(`Set ${env['ADAPTER']} PORT: ${port}`)
      return env
    })
}

portscanner

Asynchronous port scanner for Node.js

MIT
Latest version published 6 years ago

Package Health Score

74 / 100
Full package analysis