unix - Travis 启动服务器并继续执行脚本

标签 unix travis-ci

对于我的测试,我需要一个输出示例/测试代码的虚拟服务器。我为此使用了一个节点 http 服务器,并在我的脚本之前使用 node ./test/server.js 启动它。 .

我可以启动它,但问题是它占用了实例,因此现在无法运行测试。

所以问题是,我怎样才能在后台/新实例中运行服务器,以免与之冲突?我确实用 停止了服务器end_script 所以我不必终止它。

到目前为止,这是我的 travis-config:

language: node_js
node_js:
  - "6.1"
cache:
  directories:
    — node_modules
install:
  - npm install
before_script:
  - sh -e node ./test/server.js
script:
  - ./node_modules/mocha-phantomjs/bin/mocha-phantomjs ./test/browser/jelly.html
  - ./node_modules/mocha-phantomjs/bin/mocha-phantomjs ./test/browser/form.html
  - ./node_modules/mocha/bin/mocha ./test/node/jelly.js
after_script:
  - curl http://localhost:5555/close

最佳答案

您可以通过附加 & 来后台处理该进程。 :

before_script:
  - node ./test/server.js &

关于unix - Travis 启动服务器并继续执行脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41243068/

相关文章:

linux - 什么是./lks.sh : Permission denied in Linux when running a shell script?

bash - 在 Bash 脚本中计算数学表达式

github - 在 Github 拉取请求页面上显示 Travis-CI 构建状态

node.js - 如何使用travis-ci的.travis.yml为Node.js应用提供环境参数?

PostgreSQL 9.3 在 Travis 中创建用户失败

Django 应用程序在 Travis CI : server not running on localhost 中失败

C 编程时间和时钟函数

bash - 如何使用 BASH 脚本的 AWK 生成给定开始日期和结束日期的日期序列?

python - 子处理管道写入文件故障

android - 无法使用 avdmanager 创建 Travis CI android 模拟器