Travis CI.如何制作使用Faye服务器的通行证规范



Private pub gem需要额外的Faye服务器来为消息队列提供服务。它与rails服务器并行启动,命令为:rackup-private_pub.ru-s thin-E production

为了通过一些规范,还需要这个服务器。所以我在.travis.yml:中包含了它的启动命令

language: ruby
services:
  - postgresql
  - rack
before_script:
  - rackup private_pub.ru -s thin -E production
  - cp config/database.yml.travis config/database.yml
  - psql -c 'create database travis_ci_test;' -U postgres

但在构建过程中,此命令会引发错误:

0.00s$ rackup private_pub.ru -s thin -E production
/home/travis/build.sh: line 45: rackup: command not found
The command "rackup private_pub.ru -s thin -E production" failed and exited with 127 during .

我做错了什么?

找不到rackup命令。你会想要使用bundler-exec来运行rackup(假设rack等在你的Gemfile中):

before_script:
  - bundle exec rackup private_pub.ru -s thin -E production &

使用bundle exec使用gemfile中的内容,而不是系统上的内容(在这种情况下,它不在系统上,因此您会收到错误)。这里有一个很好的链接,可以解释更多关于机架和捆绑包执行器的信息:https://robots.thoughtbot.com/but-i-dont-want-to-bundle-exec

在Travis上,您也不需要将机架添加到服务中,只需将其保存在您的Gemfile中即可。:)

最新更新