How to use the get-port function in get-port

To help you get started, we’ve selected a few get-port 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 microsoft / vscode-js-debug / src / int-chrome / puppeteer / launchPuppeteer.ts View on Github external
public static async start(
    debugClient: ExtendedDebugClient,
    daConfig: IScenarioConfiguration,
    chromeArgs: string[] = [],
    callbacks: IDebugAdapterCallbacks,
  ): Promise {
    const daPort = await getPort();
    // logger.log(`About to ${daConfig.scenario} debug-adapter at port: ${daPort}`); // TODO@rob

    let browser: Browser;
    if (daConfig.scenario === 'launch') {
      await launchTestAdapter(
        debugClient,
        Object.assign({}, daConfig, { runtimeArgs: [`--remote-debugging-port=${daPort}`] }),
        callbacks,
      );
      browser = await connectPuppeteer(daPort);
    } else {
      browser = await launchPuppeteer(daPort, chromeArgs);

      // We want to attach after the page is fully loaded, and things happened, to simulate a real attach scenario. So we wait for a little bit
      await utils.promiseTimeout(undefined, 1000);
github pnpm / pnpm / packages / pnpm / src / cmd / server / start.ts View on Github external
async function getTcpOptions () {
    return {
      hostname: 'localhost',
      port: opts.port || await getPort({ port: 5813 }), // tslint:disable-line
    }
  }
github zeit / now / packages / now-static-build / src / index.ts View on Github external
meta.isDev &&
      (devCommand ||
        (pkg && devScript && pkg.scripts && pkg.scripts[devScript]))
    ) {
      let devPort: number | undefined = nowDevScriptPorts.get(entrypoint);

      if (typeof devPort === 'number') {
        debug(
          '`%s` server already running for %j',
          devCommand || devScript,
          entrypoint
        );
      } else {
        // Run the `now-dev` or `dev` script out-of-bounds, since it is assumed that
        // it will launch a dev server that never "completes"
        devPort = await getPort();
        nowDevScriptPorts.set(entrypoint, devPort);

        const opts: SpawnOptions = {
          cwd: entrypointDir,
          stdio: 'inherit',
          env: { ...spawnOpts.env, PORT: String(devPort) },
        };

        const cmd = devCommand || `yarn run ${devScript}`;
        const child: ChildProcess = spawnCommand(cmd, opts);

        child.on('exit', () => nowDevScriptPorts.delete(entrypoint));
        nowDevChildProcesses.add(child);

        // Now wait for the server to have listened on `$PORT`, after which we
        // will ProxyPass any requests to that development server that come in
github elastic / kibana / x-pack / plugins / code / server / lsp / java_launcher.ts View on Github external
public async launch(builtinWorkspace: boolean, maxWorkspace: number, installationPath: string) {
    let port = 2090;

    if (!this.options.lsp.detach) {
      port = await getPort();
    }
    const log = this.loggerFactory.getLogger(['code', `java@${this.targetHost}:${port}`]);
    const proxy = new LanguageServerProxy(port, this.targetHost, log, this.options.lsp);
    proxy.awaitServerConnection();
    if (this.options.lsp.detach) {
      // detach mode
      proxy.onConnected(() => {
        this.isRunning = true;
      });
      proxy.onDisconnected(() => {
        this.isRunning = false;
        if (!proxy.isClosed) {
          proxy.awaitServerConnection();
        }
      });
    } else {
github prisma / lift / src / Studio.ts View on Github external
throw new Error(
          `Could not find any Prisma2 query-engine binary for Studio. Looked in ${pathCandidates.join(', ')}`,
        )
      }

      const StudioServer = (await import('@prisma/studio-server')).default

      let photonWorkerPath: string | undefined
      try {
        const studioTransport = require.resolve('@prisma/studio-transports')
        photonWorkerPath = path.join(path.dirname(studioTransport), 'photon-worker.js')
      } catch (e) {
        //
      }

      this.port = await getPort({ port: getPort.makeRange(5555, 5600) })
      this.instance = new StudioServer({
        port: this.port,
        debug: false,
        binaryPath: firstExistingPath.path,
        photonWorkerPath,
        photonGenerator: {
          version: packageJson.prisma.version,
          providerAliases,
        },
        schemaPath: getDatamodelPath(this.projectDir),
        // reactAppDir: path.join(path.dirname(require.resolve('@prisma/studio/package.json')), 'build'),
      })

      await this.instance.start()

      return `Studio started at http://localhost:${this.port}`
github process-engine / bpmn-studio / electron_app / electron.ts View on Github external
const devUserDataFolderPath = path.join(__dirname, '..', 'userData');
  const prodUserDataFolderPath = app.getPath('userData');

  const userDataFolderPath = releaseChannel.isDev() ? devUserDataFolderPath : prodUserDataFolderPath;

  if (!releaseChannel.isDev()) {
    process.env.CONFIG_PATH = path.join(__dirname, '..', '..', '..', 'config');
  }

  const configForGetPort = {
    port: getPortListByVersion(releaseChannel.getVersion()),
    host: '0.0.0.0',
  };
  console.log('Trying to start internal ProcessEngine on ports:', configForGetPort);

  const port = await getPort(configForGetPort);

  console.log(`Internal ProcessEngine starting on port ${port}.`);

  process.env.http__http_extension__server__port = `${port}`;

  const processEngineDatabaseFolderName = getProcessEngineDatabaseFolderName();

  process.env.process_engine__process_model_repository__storage = path.join(
    userDataFolderPath,
    processEngineDatabaseFolderName,
    'process_model.sqlite',
  );
  process.env.process_engine__flow_node_instance_repository__storage = path.join(
    userDataFolderPath,
    processEngineDatabaseFolderName,
    'flow_node_instance.sqlite',
github elastic / kibana / x-pack / legacy / plugins / code / server / lsp / ts_launcher.ts View on Github external
async getPort() {
    if (!this.options.lsp.detach) {
      return await getPort();
    }
    return TS_LANG_DETACH_PORT;
  }
github ipfs-shipyard / ipfs-desktop / src / daemon / config.js View on Github external
for (const addr of addrs) {
    const ma = parseCfgMultiaddr(addr)
    const port = parseInt(ma.nodeAddress().port, 10)

    if (port === 0) {
      continue
    }

    const isDaemon = await checkIfAddrIsDaemon(ma.nodeAddress())

    if (isDaemon) {
      continue
    }

    const freePort = await getPort({ port: getPort.makeRange(port, port + 100) })

    if (port !== freePort) {
      const opt = showDialog({
        title: i18n.t('multipleBusyPortsDialog.title'),
        message: i18n.t('multipleBusyPortsDialog.message'),
        type: 'error',
        buttons: [
          i18n.t('multipleBusyPortsDialog.action'),
          i18n.t('close')
        ]
      })

      if (opt === 0) {
        shell.openItem(join(ipfsd.repoPath, 'config'))
      }
github sinnerschrader / feature-hub / packages / demos / src / start-server.ts View on Github external
export async function startServer(
  webpackConfigs: webpack.Configuration[],
  renderApp: AppRenderer | undefined,
  demoName?: string
): Promise {
  const port = await getPort(demoName ? {port: 3000} : undefined);
  const app = express();

  app.get('/', async (req, res) => {
    try {
      if (renderApp) {
        const renderResult = await renderApp({port, req});

        res.send(
          createDocumentHtml(`<main>${renderResult.html}</main>`, renderResult)
        );
      } else {
        res.send(createDocumentHtml(`<main></main>`));
      }
    } catch (error) {
      const documentHtml = demoName
        ? createDocumentHtml(`

get-port

Get an available port

MIT
Latest version published 2 months ago

Package Health Score

85 / 100
Full package analysis