Redis 尝试连接到 Heroku 上的本地主机而不是 REDIS_URL

2024-01-06

我有一个 Rails 应用程序,它使用 Redis 进行后台作业。在 Heroku 上,我使用 Heroku Redis 插件。当我部署到 Heroku 时,出现以下错误:

Redis::CannotConnectError: Error connecting to Redis on 127.0.0.1:6379

它似乎尝试连接到本地主机。我有两个REDIS_URL and REDIS_PROVIDERHeroku 上的环境变量。这就是我的redis.rb好像:

if Rails.env.production?
  uri = URI.parse(ENV["REDIS_URL"])
else
  uri = URI.parse("redis://localhost:6379")
end
Resque.redis = Redis.new(:host => uri.host, :port => uri.port, :password => uri.password)

这是我的Procfile:

web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
worker: env TERM_CHILD=1 bundle exec rake environment resque:work QUEUE=* COUNT=1

有什么想法为什么它不起作用吗?就算我改变了redis.rb所以它只有REDIS_URL作为 url,它给出了相同的错误。

更新:添加了错误跟踪:

remote:        Redis::CannotConnectError: Error connecting to Redis on 127.0.0.1:6379 (Errno::ECONNREFUSED)
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/redis-3.3.3/lib/redis/client.rb:345:in `rescue in establish_connection'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/redis-3.3.3/lib/redis/client.rb:331:in `establish_connection'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/redis-3.3.3/lib/redis/client.rb:101:in `block in connect'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/redis-3.3.3/lib/redis/client.rb:293:in `with_reconnect'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/redis-3.3.3/lib/redis/client.rb:100:in `connect'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/redis-3.3.3/lib/redis/client.rb:364:in `ensure_connected'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/redis-3.3.3/lib/redis/client.rb:221:in `block in process'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/redis-3.3.3/lib/redis/client.rb:306:in `logging'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/redis-3.3.3/lib/redis/client.rb:220:in `process'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/redis-3.3.3/lib/redis/client.rb:120:in `call'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/redis-3.3.3/lib/redis.rb:351:in `block in time'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/redis-3.3.3/lib/redis.rb:58:in `block in synchronize'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/redis-3.3.3/lib/redis.rb:58:in `synchronize'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/redis-3.3.3/lib/redis.rb:350:in `time'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/redis-namespace-1.5.3/lib/redis/namespace.rb:435:in `call_with_namespace'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/redis-namespace-1.5.3/lib/redis/namespace.rb:321:in `method_missing'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/resque-1.27.2/lib/resque/data_store.rb:100:in `redis_time_available?'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/resque-1.27.2/lib/resque/data_store.rb:15:in `initialize'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/resque-1.27.2/lib/resque.rb:125:in `new'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/resque-1.27.2/lib/resque.rb:125:in `redis='
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/resque-web-0.0.9/config/initializers/resque_config.rb:4:in `<top (required)>'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:287:in `load'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:287:in `block in load'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:259:in `load_dependency'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:287:in `load'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/railties-5.0.1/lib/rails/engine.rb:648:in `block in load_config_initializer'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.1/lib/active_support/notifications.rb:166:in `instrument'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/railties-5.0.1/lib/rails/engine.rb:647:in `load_config_initializer'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/railties-5.0.1/lib/rails/engine.rb:612:in `block (2 levels) in <class:Engine>'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/railties-5.0.1/lib/rails/engine.rb:611:in `each'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/railties-5.0.1/lib/rails/engine.rb:611:in `block in <class:Engine>'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/railties-5.0.1/lib/rails/initializable.rb:30:in `instance_exec'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/railties-5.0.1/lib/rails/initializable.rb:30:in `run'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/railties-5.0.1/lib/rails/initializable.rb:55:in `block in run_initializers'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/railties-5.0.1/lib/rails/initializable.rb:44:in `each'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/railties-5.0.1/lib/rails/initializable.rb:44:in `tsort_each_child'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/railties-5.0.1/lib/rails/initializable.rb:54:in `run_initializers'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/railties-5.0.1/lib/rails/application.rb:352:in `initialize!'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/config/environment.rb:5:in `<top (required)>'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:293:in `require'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:293:in `block in require'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:259:in `load_dependency'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:293:in `require'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/railties-5.0.1/lib/rails/application.rb:328:in `require_environment!'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/railties-5.0.1/lib/rails/application.rb:448:in `block in run_tasks_blocks'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/sprockets-rails-3.2.0/lib/sprockets/rails/task.rb:62:in `block (2 levels) in define'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/exe/rake:27:in `<top (required)>'
remote:        Errno::ECONNREFUSED: Connection refused - connect(2) for 127.0.0.1:6379
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/redis-3.3.3/lib/redis/connection/ruby.rb:206:in `rescue in connect_addrinfo'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/redis-3.3.3/lib/redis/connection/ruby.rb:198:in `connect_addrinfo'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/redis-3.3.3/lib/redis/connection/ruby.rb:239:in `block in connect'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/redis-3.3.3/lib/redis/connection/ruby.rb:237:in `each'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/redis-3.3.3/lib/redis/connection/ruby.rb:237:in `each_with_index'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/redis-3.3.3/lib/redis/connection/ruby.rb:237:in `connect'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/redis-3.3.3/lib/redis/connection/ruby.rb:313:in `connect'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/redis-3.3.3/lib/redis/client.rb:336:in `establish_connection'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/redis-3.3.3/lib/redis/client.rb:101:in `block in connect'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/redis-3.3.3/lib/redis/client.rb:293:in `with_reconnect'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/redis-3.3.3/lib/redis/client.rb:100:in `connect'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/redis-3.3.3/lib/redis/client.rb:364:in `ensure_connected'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/redis-3.3.3/lib/redis/client.rb:221:in `block in process'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/redis-3.3.3/lib/redis/client.rb:306:in `logging'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/redis-3.3.3/lib/redis/client.rb:220:in `process'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/redis-3.3.3/lib/redis/client.rb:120:in `call'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/redis-3.3.3/lib/redis.rb:351:in `block in time'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/redis-3.3.3/lib/redis.rb:58:in `block in synchronize'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/redis-3.3.3/lib/redis.rb:58:in `synchronize'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/redis-3.3.3/lib/redis.rb:350:in `time'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/redis-namespace-1.5.3/lib/redis/namespace.rb:435:in `call_with_namespace'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/redis-namespace-1.5.3/lib/redis/namespace.rb:321:in `method_missing'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/resque-1.27.2/lib/resque/data_store.rb:100:in `redis_time_available?'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/resque-1.27.2/lib/resque/data_store.rb:15:in `initialize'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/resque-1.27.2/lib/resque.rb:125:in `new'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/resque-1.27.2/lib/resque.rb:125:in `redis='
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/resque-web-0.0.9/config/initializers/resque_config.rb:4:in `<top (required)>'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:287:in `load'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:287:in `block in load'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:259:in `load_dependency'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:287:in `load'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/railties-5.0.1/lib/rails/engine.rb:648:in `block in load_config_initializer'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.1/lib/active_support/notifications.rb:166:in `instrument'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/railties-5.0.1/lib/rails/engine.rb:647:in `load_config_initializer'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/railties-5.0.1/lib/rails/engine.rb:612:in `block (2 levels) in <class:Engine>'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/railties-5.0.1/lib/rails/engine.rb:611:in `each'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/railties-5.0.1/lib/rails/engine.rb:611:in `block in <class:Engine>'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/railties-5.0.1/lib/rails/initializable.rb:30:in `instance_exec'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/railties-5.0.1/lib/rails/initializable.rb:30:in `run'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/railties-5.0.1/lib/rails/initializable.rb:55:in `block in run_initializers'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/railties-5.0.1/lib/rails/initializable.rb:44:in `each'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/railties-5.0.1/lib/rails/initializable.rb:44:in `tsort_each_child'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/railties-5.0.1/lib/rails/initializable.rb:54:in `run_initializers'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/railties-5.0.1/lib/rails/application.rb:352:in `initialize!'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/config/environment.rb:5:in `<top (required)>'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:293:in `require'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:293:in `block in require'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:259:in `load_dependency'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:293:in `require'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/railties-5.0.1/lib/rails/application.rb:328:in `require_environment!'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/railties-5.0.1/lib/rails/application.rb:448:in `block in run_tasks_blocks'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/sprockets-rails-3.2.0/lib/sprockets/rails/task.rb:62:in `block (2 levels) in define'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/exe/rake:27:in `<top (required)>'
remote:        IO::EINPROGRESSWaitWritable: Operation now in progress - connect(2) would block
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/redis-3.3.3/lib/redis/connection/ruby.rb:199:in `connect_addrinfo'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/redis-3.3.3/lib/redis/connection/ruby.rb:239:in `block in connect'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/redis-3.3.3/lib/redis/connection/ruby.rb:237:in `each'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/redis-3.3.3/lib/redis/connection/ruby.rb:237:in `each_with_index'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/redis-3.3.3/lib/redis/connection/ruby.rb:237:in `connect'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/redis-3.3.3/lib/redis/connection/ruby.rb:313:in `connect'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/redis-3.3.3/lib/redis/client.rb:336:in `establish_connection'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/redis-3.3.3/lib/redis/client.rb:101:in `block in connect'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/redis-3.3.3/lib/redis/client.rb:293:in `with_reconnect'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/redis-3.3.3/lib/redis/client.rb:100:in `connect'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/redis-3.3.3/lib/redis/client.rb:364:in `ensure_connected'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/redis-3.3.3/lib/redis/client.rb:221:in `block in process'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/redis-3.3.3/lib/redis/client.rb:306:in `logging'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/redis-3.3.3/lib/redis/client.rb:220:in `process'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/redis-3.3.3/lib/redis/client.rb:120:in `call'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/redis-3.3.3/lib/redis.rb:351:in `block in time'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/redis-3.3.3/lib/redis.rb:58:in `block in synchronize'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/redis-3.3.3/lib/redis.rb:58:in `synchronize'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/redis-3.3.3/lib/redis.rb:350:in `time'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/redis-namespace-1.5.3/lib/redis/namespace.rb:435:in `call_with_namespace'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/redis-namespace-1.5.3/lib/redis/namespace.rb:321:in `method_missing'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/resque-1.27.2/lib/resque/data_store.rb:100:in `redis_time_available?'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/resque-1.27.2/lib/resque/data_store.rb:15:in `initialize'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/resque-1.27.2/lib/resque.rb:125:in `new'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/resque-1.27.2/lib/resque.rb:125:in `redis='
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/resque-web-0.0.9/config/initializers/resque_config.rb:4:in `<top (required)>'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:287:in `load'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:287:in `block in load'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:259:in `load_dependency'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:287:in `load'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/railties-5.0.1/lib/rails/engine.rb:648:in `block in load_config_initializer'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.1/lib/active_support/notifications.rb:166:in `instrument'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/railties-5.0.1/lib/rails/engine.rb:647:in `load_config_initializer'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/railties-5.0.1/lib/rails/engine.rb:612:in `block (2 levels) in <class:Engine>'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/railties-5.0.1/lib/rails/engine.rb:611:in `each'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/railties-5.0.1/lib/rails/engine.rb:611:in `block in <class:Engine>'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/railties-5.0.1/lib/rails/initializable.rb:30:in `instance_exec'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/railties-5.0.1/lib/rails/initializable.rb:30:in `run'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/railties-5.0.1/lib/rails/initializable.rb:55:in `block in run_initializers'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/railties-5.0.1/lib/rails/initializable.rb:44:in `each'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/railties-5.0.1/lib/rails/initializable.rb:44:in `tsort_each_child'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/railties-5.0.1/lib/rails/initializable.rb:54:in `run_initializers'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/railties-5.0.1/lib/rails/application.rb:352:in `initialize!'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/config/environment.rb:5:in `<top (required)>'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:293:in `require'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:293:in `block in require'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:259:in `load_dependency'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:293:in `require'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/railties-5.0.1/lib/rails/application.rb:328:in `require_environment!'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/railties-5.0.1/lib/rails/application.rb:448:in `block in run_tasks_blocks'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/sprockets-rails-3.2.0/lib/sprockets/rails/task.rb:62:in `block (2 levels) in define'
remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/exe/rake:27:in `<top (required)>'
remote:        Tasks: TOP => environment
remote:        (See full trace by running task with --trace)
remote:  !
remote:  !     Precompiling assets failed.
remote:  !     Attempted to access a nonexistent database:
remote:  !     https://devcenter.heroku.com/articles/pre-provision-database
remote:  !
remote:  !     Push rejected, failed to compile Ruby app.
remote: 
remote:  !     Push failed
remote: Verifying deploy....
remote: 
remote: !   Push rejected to backbone-app-staging.
remote: 
To [email protected] /cdn-cgi/l/email-protection:backbone-app-staging.git
 ! [remote rejected] rails5 -> master (pre-receive hook declined)
error: failed to push some refs to '[email protected] /cdn-cgi/l/email-protection:backbone-app-staging.git'

我能想到两种可能性:

  • 是否有设置ENV['REDIS_URL']在初始化程序运行之前?例如,也许你有一个.env文件检入 git 并覆盖 Heroku 变量?

  • 你说这段代码来自redis.rb。你有没有config/initializers/resque.rb还?关于什么config/resque.yml?其中任何一个都可能是also尝试打开 Redis 连接。 (如果您可以发布错误的整个堆栈跟踪,您就可以确认这一点或排除它。)或者您是否将 Redis 用于 Resque 之外的其他用途?

您还可以进行一些 printf 调试并将初始化程序更改为:

if Rails.env.production?
  puts "production: #{ENV['REDIS_URL']}"
  uri = URI.parse(ENV["REDIS_URL"])
else
  puts "not production"
  uri = URI.parse("redis://localhost:6379")
end

这应该可以帮助您弄清楚发生了什么。 (您可能需要使用Rails.logger.info代替puts.)

EDIT:该堆栈跟踪非常有帮助!果然,您自己的初始化程序根本不在那里,但还有其他代码尝试加载自己的 Redis 连接,如下所示:

remote:        /tmp/build_329306a238b046dda86a54d29db48f4c/vendor/bundle/ruby/2.4.0/gems/resque-web-0.0.9/config/initializers/resque_config.rb:4:in `<top (required)>'

If you 查找那颗宝石 https://github.com/resque/resque-web/blob/v0.0.9/config/initializers/resque_config.rb,你可以看到它正在这样做:

require 'resque'

config = ENV.fetch("RAILS_RESQUE_REDIS", "127.0.0.1:6379")
Resque.redis = config

所以我认为答案是设置RAILS_RESQUE_REDIS 此外 to REDIS_URL。您可以使用 Herokuconfig:set命令执行此操作。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Redis 尝试连接到 Heroku 上的本地主机而不是 REDIS_URL 的相关文章

随机推荐

  • Django - 网络商店模型组织

    我开始在 Django 中创建一个网上商店 它将有不同种类的产品 如衬衫 海报 杯子 贴纸 每种类型的产品都会有不同的领域 例如 衬衫有尺寸和颜色选项 贴纸有尺寸选项 海报和马克杯没有选项 做这个的最好方式是什么 遗产 关系 我仍在学习 D
  • 数据读取器跳过第一个结果

    我有一个相当复杂的 SQL 查询 它根据客户 ID 从数据库中提取不同类型的产品 它提取三种不同类型的产品 通过其唯一标识符编号范围进行标识 即 ID 1000 1999 是一种产品类型 2000 2999 是另一种产品类型 3000 39
  • Angular JS - 如何在 ng-repeat 中添加额外的 DIV

    我有一个数组a 1 2 3 4 5 6 Using ng repeat在这个数组上 我创建了 6 个divs 请参考这个plunker http plnkr co edit fe4nTUFQ9ojEyBsyrOtH p preview 有没
  • SQL 存档脚本

    我正在尝试将数据库中的表中的记录存档到存档数据库中的相同表 我需要能够对日期大于三年前的所有记录进行插入 然后删除这些行 然而 这个表有数百万条实时记录 所以我想在一次大约 100 到 1000 个块的循环中运行它 到目前为止 我的存储过程
  • 双三次插值如何工作?

    在阅读有关该主题的文本后 我发现它考虑了 16 个原始相邻像素 我想知道的是它如何计算新像素的颜色值 如果 16 个像素的颜色值已知 如何计算新像素的值 我认为这已经很好地解释了维基百科 http en wikipedia org wiki
  • 如何在 R 中为新函数绘制 CDF 和 PDF

    如何在 R 中绘制 CDF 和 PDF f lt function x 2 a b x 3 exp b x 2 a 范围从 0 到无穷大 我会使用这样的东西 因为我喜欢ggplot2 a lt 1 b lt 2 f lt function
  • Visual Studio 和 Unity 中使用 MDB 文件进行构建后事件

    我在 Unity 中的 MonoBehaviours 源代码不是 Assets 文件夹内的脚本 而是我作为插件添加的已编译 DLL 我在 Visual Studio 中为我的 C 项目添加了生成后事件 以尝试解决每次更改某些内容时都必须复制
  • Node.js 子进程——spawn 和 fork 之间的区别

    这似乎是一个基本问题 但我找不到任何文档 分叉和生成 Node js 进程有什么区别 我读过分叉是生成的一种特殊情况 但是使用它们每个的不同用例 重复是什么 Spawn 是一个旨在运行系统命令的命令 当您运行spawn时 您向其发送一个系统
  • 如何动态下载字体并将其安装到 iOS 应用程序

    客户希望通过 API 调用下载字体来动态地将字体添加到 iOS 应用程序中 这可能吗 我挖掘出的所有资源都展示了如何手动将 ttf 文件拖到 Xcode 并将其添加到 plist 中 是否可以下载字体并以编程方式在客户端上使用它 Thank
  • App Engine 实例中 /_ah/start 的日志

    我的 App Engine 实例中有一个映射到 url ah start 的 servlet 它似乎不起作用 我无法像处理所有其他请求那样从此 servlet 中找到日志记录信息 由于它应该作为单独的线程运行 因此我无法在自定义请求中手动测
  • 未能找到带有哈希字符串 android-23 的目标

    当尝试从 git github com osmdroid osmdroid 构建 OpenStreetMapView 时 出现以下错误 failed to find target with hash string android 23 D
  • 角度依赖注入导出函数

    我正在使用 apollo graphql 它有一个模块 里面有一个函数 export function createApollo httpLink HttpLink connectToDevTools true 在此函数内 您定义 grap
  • mysql n:m 关系:查找具有多个特定关系的行

    我有两个 SQL 表 产品 和 标签 它们具有 n m 关系 使用第三个表 product tags 我想使用查询来查找具有多个特定标签的每个产品 例如 查找与标签 1 23 和 54 相关的所有产品 有没有办法只用一个查询来做到这一点 您
  • 将驱动程序对象的单个实例传递给所有其他类(Testng 框架)

    我有一个在类示例中初始化的驱动程序对象 我也想将驱动程序对象传递给其他类 但我得到一个空指针异常 我的代码是 样本类 public class sample WebDriver driver Test priority 1 public v
  • 用于 POST 请求的 Django Rest 框架自定义过滤器

    在filters py中 我有一个CustomFilter定义了具有类型值的ComboSortFilter and IntegerListFilter 在views py中 我定义了一个ViewSet 它具有filter class Cus
  • 我可以使用在启动期间配置的 MvcJsonOptions 在自定义中间件中进行序列化吗?

    我正在构建一个带有用于全局异常处理的中间件的 ASP NET Core Api 在Startup类中 我配置了一些用于所有控制器的 JSON 选项 public void ConfigureServices IServiceCollecti
  • TensorFlow 的内存泄漏

    我的 TensorFlow 出现内存泄漏 我提到了Tensorflow 即使关闭会话也会发生内存泄漏 https stackoverflow com questions 35695183 tensorflow memory leak eve
  • Vue.js filterBy 在多个字段中搜索

    如何通过在多个搜索键中搜索来进行过滤 我正在尝试这样的事情 但是 当然 它不会起作用 tr AFAIK 没有记录 filterBy 自定义过滤器 但您可以使用method制作你自己的过滤器 var demo new Vue el demo
  • 只能使用绝对 URI 作为基地址

    请帮助获得例外using ServiceHost host new ServiceHost typeof HelloService HelloService 在下面的代码中 例外 只有绝对 URI 可以用作基地址 WCF 主机应用程序 cl
  • Redis 尝试连接到 Heroku 上的本地主机而不是 REDIS_URL

    我有一个 Rails 应用程序 它使用 Redis 进行后台作业 在 Heroku 上 我使用 Heroku Redis 插件 当我部署到 Heroku 时 出现以下错误 Redis CannotConnectError Error con