當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript portfinder.getPort函數代碼示例

本文整理匯總了TypeScript中portfinder.getPort函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript getPort函數的具體用法?TypeScript getPort怎麽用?TypeScript getPort使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了getPort函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: Promise

            return new Promise((resolve, reject) => {
                PortFinder.getPort((err, port) => {
                    let fatJar = Path.resolve(context.extensionPath, "out", "fat-jar.jar");
                    
                    let args = [
                        '-cp', fatJar, 
                        '-Djavacs.port=' + port,
                        'org.javacs.Main'
                    ];
                    
                    console.log(javaExecutablePath + ' ' + args.join(' '));
                    
                    Net.createServer(socket => {
                        console.log('Child process connected on port ' + port);

                        resolve({
                            reader: socket,
                            writer: socket
                        });
                    }).listen(port, () => {
                        let options = { stdio: 'inherit', cwd: VSCode.workspace.rootPath };
                        
                        // Start the child java process
                        ChildProcess.execFile(javaExecutablePath, args, options);
                    });
                });
            });
開發者ID:alexsaveliev,項目名稱:vscode-javac,代碼行數:27,代碼來源:Main.ts

示例2: function

 function(callback) {
   const host = '0.0.0.0';
   getPort({port: 8080, host: host}, function(err, port) {
     if (err) { throw err; }
     createServer(requestListener).listen(port, host, function(err: any) {
       callback(err, `http://${host}:${port}`);
     });
   });
 },
開發者ID:wereHamster,項目名稱:devlisten,代碼行數:9,代碼來源:index.ts

示例3: beforeAll

 beforeAll((done) => {
   portfinder.getPort((err: Error, p: number) => {
     if (err) {
       done.fail(err);
     } else {
       port = p;
       server = new MockAppium(port);
       server.start();
       done();
     }
   });
 });
開發者ID:angular,項目名稱:webdriver-js-extender,代碼行數:12,代碼來源:helpers.ts

示例4: Observable

 return new Observable(obs => {
   portfinder.basePort = basePort;
   // tslint:disable:no-any
   portfinder.getPort({ port, host }, (err: any, foundPort: number) => {
     if (err) {
       obs.error(err);
     } else if (port !== foundPort && port !== 0) {
       // If the port isn't available and we weren't looking for any port, throw error.
       obs.error(`Port ${port} is already in use. Use '--port' to specify a different port.`);
     } else {
       // Otherwise, our found port is good.
       obs.next(foundPort);
       obs.complete();
     }
   });
 });
開發者ID:baconwaffles,項目名稱:angular-cli,代碼行數:16,代碼來源:check-port.ts

示例5: Promise

 return new Promise((resolve, reject) => {
     PortFinder.getPort((err, port) => {
         if (port != PortFinder.basePort) {
             console.log("Port in use, connect instead of create.");
             let socket = Net.createConnection({port: PortFinder.basePort}, () => {
                 console.log('connected to server!');
             });
             socket.on("connect", () => {
                 resolve({
                     reader: socket,
                     writer: socket
                 });
             });                        
         } else {
             /*
             let fatJar = Path.resolve(context.extensionPath, "out", "fat-jar.jar");
             
             let args = [
                 '-cp', fatJar, 
                 '-Djavacs.port=' + port,
                 'org.javacs.Main'
             ];
             
             console.log(javaExecutablePath + ' ' + args.join(' '));
             
             Net.createServer(socket => {
                 console.log('Child process connected on port ' + port);
                 resolve({
                     reader: socket,
                     writer: socket
                 });
             }).listen(port, () => {
                 let options = { stdio: 'inherit', cwd: VSCode.workspace.rootPath };
                 
                 // Do not start the child java process (debugging)
                 ChildProcess.execFile(javaExecutablePath, args, options);
             });
             */
             console.log("cannot connect to language server");
         }
     });
 });
開發者ID:xuy,項目名稱:vscode-javac,代碼行數:42,代碼來源:Main.ts

示例6: require

// Start listening
const portfinder = require('portfinder');
portfinder.basePort = clOptions.port;
portfinder.getPort(function (err, port) {
    if (err) {
        console.error(err);
        exit(errorCodes.couldNotListen);
    }
    /** If the user *did* specify a port and we end up not using it */
    if (clOptions.port !== cl.defaultPort
        && port !== clOptions.port) {
        console.log(chalk.magenta(`[WEB] WARNING: Desired port is not available so using port ${port}`));
    }
    server.listen(port, clOptions.host, function(err) {
        if (err) {
            console.error(err);
            exit(errorCodes.couldNotListen);
        }
        const host = clOptions.host in {'localhost':true,'127.0.0.1':true,'0.0.0.0': true} ? 'localhost' : clOptions.host
        console.log(`DASHBOARD:`, chalk.green(`http://${host}:${port}`));
        if (clOptions.open) {
            open(`http://${host}:${port}`);
        }
        serverStarted.started();
    });
});

/**
 * Notify user of updates
 */
開發者ID:JeyKeu,項目名稱:alm,代碼行數:30,代碼來源:server.ts

示例7: resolve

    return new Promise<any>((resolve, reject) => {
      portFinder.getPort((err, port) => {
        const uberJar = path.resolve(
          context.extensionPath,
          'out',
          UBER_JAR_NAME
        );
        const javaExecutable = path.resolve(
          `${requirementsData.java_home}/bin/java`
        );
        let args: string[];
        if (DEBUG) {
          args = [
            '-cp',
            uberJar,
            `-Dapex-lsp.port=${port}`,
            '-Ddebug.internal.errors=true',
            '-Ddebug.semantic.errors=false',
            '-Dtrace.protocol=false',
            `-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=${JDWP_DEBUG_PORT}`,
            APEX_LANGUAGE_SERVER_MAIN
          ];
        } else {
          args = [
            '-cp',
            uberJar,
            `-Dapex-lsp.port=${port}`,
            '-Ddebug.internal.errors=true',
            '-Ddebug.semantic.errors=false',
            APEX_LANGUAGE_SERVER_MAIN
          ];
        }

        net
          .createServer(socket => {
            resolve({
              reader: socket,
              writer: socket
            });
          })
          .listen(port, () => {
            const options = {
              cwd: vscode.workspace.rootPath
            };

            const lspProcess = child_process.spawn(
              javaExecutable,
              args,
              options
            );
            console.log('PROCESS INFO');
            console.log(lspProcess);

            lspProcess.stdout.on('data', data => {
              APEX_LANGUAGE_SERVER_CHANNEL.appendLine(`${data}`);
            });
            lspProcess.stderr.on('data', data => {
              APEX_LANGUAGE_SERVER_CHANNEL.appendLine(`${data}`);
            });
            lspProcess.on('close', code => {
              APEX_LANGUAGE_SERVER_CHANNEL.appendLine(
                `${nls.localize('client_name')} exited with code: ${code}`
              );
            });
          });
      });
    });
開發者ID:nertofiveone,項目名稱:salesforcedx-vscode,代碼行數:67,代碼來源:languageServer.ts

示例8: register

// Setup a socket server
import {register} from "./socket/socketServer";
register(server);

// Start listening
var portfinder = require('portfinder');
portfinder.basePort = clOptions.port;
portfinder.getPort(function (err, port) {
    if (err) {
        console.error(err);
        exit(errorCodes.couldNotListen);
    }
    server.listen(port, function(err) {
        if (err) {
            console.error(err);
            exit(errorCodes.couldNotListen);
        }
        console.log(`Dashboard at http://localhost:${port}`);
        if (clOptions.open) {
            open(`http://localhost:${port}`);
        }
        serverStarted.started();
    });
});

/**
 * Notify user of updates
 */
var pkg = require('../package.json');
require('update-notifier')({
  pkg,
開發者ID:trenchmortar,項目名稱:alm,代碼行數:31,代碼來源:server.ts

示例9:

 const port = await fromCallback<number>(cb => portfinder.getPort(cb));
開發者ID:cspotcode,項目名稱:easy-node-inspector,代碼行數:1,代碼來源:easy-node-debug.ts

示例10: require

import hapi = require("hapi");
import Promise = require("bluebird");
import log = require("./log");
import allRoutes = require("./routes/all");
import todo = require("./routes/todo/items");
var portFinder = require("portfinder");

var server = new hapi.Server();
portFinder.getPort((err, port) => {

    log.debug("Fetched port: " + port);
    port = port;
    startServer(port);
});

function startServer(port: number) {
    server.connection({
        port: port
    });

    for (var route in allRoutes) server.route(allRoutes[route]);

    server.start(() => {
        log.info("Server listening on port " + port);
        seedData();
    });
}

function seedData() {
    var data = [
        { id: 1, message: "first item", isDone: 0 },
開發者ID:djm204,項目名稱:todo-backend,代碼行數:31,代碼來源:index.ts


注:本文中的portfinder.getPort函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。