[英]GiLab CI - Redis::CannotConnectError: Error connecting to Redis on 127.0.0.1:6379
Few tests are failing in pipeline with error Redis::CannotConnectError: Error connecting to Redis on 127.0.0.1:6379 (Errno::ECONNREFUSED)
. 很少有测试在管道中失败,并显示错误
Redis::CannotConnectError: Error connecting to Redis on 127.0.0.1:6379 (Errno::ECONNREFUSED)
。
My .gitlab-ci.yml
file 我的
.gitlab-ci.yml
文件
image: starefossen/ruby-node:latest
services:
- mongo:latest
- redis:latest
variables:
MONGODB_URI: mongodb://mongo:27017/db_test
REDISTOGO_URL: redis://localhost:6379
before_script:
- bundle install --path=cache/bundler
- cp config/mongoid.yml.gitlab config/mongoid.yml
- RAILS_ENV=test bundle exec rake db:create db:migrate
test:
script:
- bundle exec rake test
my config/initializers/sidekiq.rb
file 我的
config/initializers/sidekiq.rb
文件
require 'sidekiq'
require 'sidekiq-status'
Sidekiq.configure_client do |config|
config.redis = { size: 5, url: ENV['REDISTOGO_URL'] }
end
Sidekiq.configure_server do |config|
config.server_middleware do |chain|
chain.add Sidekiq::Throttler, storage: :redis
end
config.redis = { size: 10, url: ENV['REDISTOGO_URL'] }
end
can anyone point me the right direction? 谁能为我指出正确的方向? Thank you
谢谢
There's no one single localhost in Docker which is used by Gitlab CI. Gitlab CI使用的Docker中没有一个本地主机。 The convention is that the service name declared below will be available for other containers in the docker network by it's name -
redis
in that case: 约定是,以下声明的服务名称将通过其名称可用于docker网络中的其他容器-在这种情况下,
redis
:
services:
- redis:latest
So replacing localhost
with redis
should be enough: 因此,用
redis
替换localhost
就足够了:
variables:
- REDISTOGO_URL: redis://localhost:6379
+ REDISTOGO_URL: redis://redis:6379
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.