对于我的测试,我需要一个输出示例/测试代码的虚拟服务器。我为此使用了一个节点 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/