• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript portfinder.getPort函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript portscanner.checkPortStatus函数代码示例发布时间:2022-05-25
下一篇:
TypeScript popsicle.request函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap