web-dev-qa-db-ja.com

Redisは、REDIS_URLではなくHerokuのローカルホストに接続しようとします

バックグラウンドジョブにRedisを使用するRailsアプリがあります。Herokuでは、Heroku Redisアドオンを使用しています。Herokuにデプロイすると、次のエラーが発生します。

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

ローカルホストに接続しようとしているようです。 HerokuにREDIS_URLREDIS_PROVIDERの両方の環境変数があります。そして、これは私の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を変更してURLとしてREDIS_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]:backbone-app-staging.git
 ! [remote rejected] Rails5 -> master (pre-receive hook declined)
error: failed to Push some refs to '[email protected]:backbone-app-staging.git'
20
John

私は2つの可能性を考えることができます:

  • イニシャライザが実行される前にENV['REDIS_URL']を設定していますか?たとえば、Heroku変数をオーバーライドしている.envファイルをgitにチェックインしている可能性がありますか?

  • このコードはredis.rbからのものだとあなたは言います。 config/initializers/resque.rbもありますか? config/resque.ymlはどうですか?それらのいずれかがまた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

それはあなたが何が起こっているのかを明確にするのに役立つはずです。 (putsの代わりにRails.logger.infoを使用する必要がある場合があります。)

編集:そのスタックトレースは非常に役立ちます!案の定、独自のイニシャライザーはまったく含まれていませんが、独自の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)>'

そのgemを検索 の場合、これを実行していることがわかります。

require 'resque'

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

したがって、答えはRails_RESQUE_REDISに加えてREDIS_URLに設定することだと思います。これを行うには、Heroku config:setコマンドを使用できます。

7

USERNAMEをコネクタに渡すのを忘れたため、REDIS_URLがサービスプロバイダーによって変更された可能性があります...

使用をお勧めします

$redis = if Rails.env.production? ? Redis.new(ENV["REDIS_URL"]) : Redis.new("redis://localhost:6379")

プランを更新するときやインフラストラクチャを変更する必要があるときなど、何らかの動機のURLを変更する場合は、サービスプロバイダーが設定したenv変数(ENV['REDISCLOUD_URL']など)を使用することをお勧めします。それらの変数を設定すると、サービスを中断することなく、透過的になります。

自分でREDIS_URLを維持し、彼らがURLを変更した場合、URLを変更する必要があると判断し、REDIS_URLを再度設定するまで、アプリはアクセスできなくなります。

[〜#〜] obs [〜#〜]

問題がワーカーのセットアップ時である場合...問題は、それが正しい環境で開始されていないことでさえある可能性があります。少なくともRails 5で実行する場合は、 Rakefileを

#If you're using Rails 5.x, include the following in lib/tasks/resque.rb:

require 'resque/tasks'
task 'resque:setup' => :environment
3
cefigueiredo

config/initializes/set_redis_url.rbの内部

ENV['REDIS_URL'] = ENV["REDISCLOUD_URL"] if ENV["REDISCLOUD_URL"]

私の過去には、アクションケーブルを使用してredisを操作していましたが、config/environments/production.rbにこれらの行がないとアプリは機能しませんでした。

config.action_cable.allowed_request_origins = ['https://your-app.herokuapp.com',
                                           'http://your-app.herokuapp.com']

config.action_cable.url = "wss://sitepoint-custom-messaging.herokuapp.com/cable"
2

Herokuに_Redis to go_アドオンを追加する必要があります

この行を置き換えます。 URI.parse("redis://localhost:6379") with

設定のREDISTOGO_URLとherokuの_Config Vars_からRedisリンクを取得します

_URI.parse("redis://redistogo:72adffd1a5bf8ffdffddfdafdfdfdaferjaw.redistogo.com:10289")
_

for Rails 6〜>これを行う

_  url: <%= ENV.fetch("REDIS_URL") { "redis://redistogo:72adffd1a5bf8fe74a2c05fdfdafdfreefdfaderjaw.redistogo.com:12317/" } %>
_

これらはダミーリンクです

0
ispirett