【问题标题】:How to run multiple shell commands incluiding Node.js server? Ubuntu如何运行包括 Node.js 服务器的多个 shell 命令? Ubuntu
【发布时间】:2021-04-21 08:20:10
【问题描述】:

我有一个脚本可以顺序执行以下 2 条指令:

node server.js
node tests.js
  • Server.js 初始化本地 Node.js + Express 服务器
  • Tests.js 在该服务器上执行一些单元测试

问题是第一条指令一直在监听请求,所以第二条指令永远不会执行。

是否有可能解决这种行为?

【问题讨论】:

    标签: node.js linux shell ubuntu


    【解决方案1】:

    我建议你使用 npm 包 start-server-and-test 确保你的 api 服务器已准备好进行测试

    start-server-and-test 'node server.js' http://localhost:{API_PORT}/ 'node tests.js'
    

    【讨论】:

      猜你喜欢
      • 2015-06-16
      • 1970-01-01
      • 2017-10-29
      • 1970-01-01
      • 1970-01-01
      • 2019-05-23
      • 2021-11-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多