【问题标题】:Error deploying Rails 4 App to Heroku redis将 Rails 4 应用程序部署到 Heroku redis 时出错
【发布时间】:2018-05-15 17:13:41
【问题描述】:

我有一年的时间在 heroku 中部署我的 rails 应用程序没有问题,但最近当我尝试推送应用程序时它只是崩溃了。我使用heroku local对其进行了测试,它可以工作,但在heroku上却不行。

我没有更改 conf 文件上的任何内容,只是突然在 heroku 上不起作用

Starting process with command `bundle exec puma -C config/puma.rb`
[4] Puma starting in cluster mode...
[4] * Version 3.11.0 (ruby 2.3.1-p112), codename: Love Song
[4] * Min threads: 2, max threads: 2
[4] * Environment: production
[4] * Process workers: 1
[4] * Preloading application
[4] ! Unable to load application: Redis::CannotConnectError: Error connecting to Redis on localhost:6379 (Errno::ECONNREFUSED)
bundler: failed to load command: puma (/app/vendor/bundle/ruby/2.3.0/bin/puma)
Redis::CannotConnectError: Error connecting to Redis on localhost:6379 (Errno::ECONNREFUSED)
   /app/vendor/bundle/ruby/2.3.0/gems/redis-4.0.1/lib/redis/client.rb:344:in `rescue in establish_connection'
   /app/vendor/bundle/ruby/2.3.0/gems/redis-4.0.1/lib/redis/client.rb:329:in `establish_connection'
   /app/vendor/bundle/ruby/2.3.0/gems/redis-4.0.1/lib/redis/client.rb:99:in `block in connect'
   /app/vendor/bundle/ruby/2.3.0/gems/redis-4.0.1/lib/redis/client.rb:291:in `with_reconnect'
   /app/vendor/bundle/ruby/2.3.0/gems/redis-4.0.1/lib/redis/client.rb:98:in `connect'
   /app/vendor/bundle/ruby/2.3.0/gems/redis-4.0.1/lib/redis/client.rb:363:in `ensure_connected'
   /app/vendor/bundle/ruby/2.3.0/gems/redis-4.0.1/lib/redis/client.rb:219:in `block in process'
   /app/vendor/bundle/ruby/2.3.0/gems/redis-4.0.1/lib/redis/client.rb:304:in `logging'
   /app/vendor/bundle/ruby/2.3.0/gems/redis-4.0.1/lib/redis/client.rb:218:in `process'
   /app/vendor/bundle/ruby/2.3.0/gems/redis-4.0.1/lib/redis/client.rb:118:in `call'
   /app/vendor/bundle/ruby/2.3.0/gems/redis-4.0.1/lib/redis.rb:1423:in `block in smembers'
   /app/vendor/bundle/ruby/2.3.0/gems/redis-4.0.1/lib/redis.rb:45:in `block in synchronize'
   /app/vendor/ruby-2.3.1/lib/ruby/2.3.0/monitor.rb:214:in `mon_synchronize'
   /app/vendor/bundle/ruby/2.3.0/gems/redis-4.0.1/lib/redis.rb:45:in `synchronize'
   /app/vendor/bundle/ruby/2.3.0/gems/redis-4.0.1/lib/redis.rb:1422:in `smembers'
   /app/vendor/bundle/ruby/2.3.0/gems/redis-namespace-1.6.0/lib/redis/namespace.rb:442:in `call_with_namespace'
   /app/vendor/bundle/ruby/2.3.0/gems/redis-namespace-1.6.0/lib/redis/namespace.rb:328:in `method_missing'
   /app/vendor/bundle/ruby/2.3.0/gems/resque-1.27.4/lib/resque/data_store.rb:236:in `worker_ids'
   /app/vendor/bundle/ruby/2.3.0/gems/resque-1.27.4/lib/resque/worker.rb:72:in `all'
   /app/vendor/bundle/ruby/2.3.0/gems/resque-1.27.4/lib/resque.rb:464:in `workers'
   /app/config/application.rb:44:in `<class:Application>'
   /app/config/application.rb:13:in `<module:Truckbu>'
   /app/config/application.rb:12:in `<top (required)>'
   /app/config/environment.rb:2:in `require'
   /app/config/environment.rb:2:in `<top (required)>'
   config.ru:3:in `require'
   config.ru:3:in `block in <main>'
   /app/vendor/bundle/ruby/2.3.0/gems/rack-1.6.8/lib/rack/builder.rb:55:in `instance_eval'
   /app/vendor/bundle/ruby/2.3.0/gems/rack-1.6.8/lib/rack/builder.rb:55:in `initialize'
   config.ru:in `new'
   config.ru:in `<main>'
   /app/vendor/bundle/ruby/2.3.0/gems/rack-1.6.8/lib/rack/builder.rb:49:in `eval'
   /app/vendor/bundle/ruby/2.3.0/gems/rack-1.6.8/lib/rack/builder.rb:49:in `new_from_string'
   /app/vendor/bundle/ruby/2.3.0/gems/rack-1.6.8/lib/rack/builder.rb:40:in `parse_file'
   /app/vendor/bundle/ruby/2.3.0/gems/puma-3.11.0/lib/puma/configuration.rb:318:in `load_rackup'
   /app/vendor/bundle/ruby/2.3.0/gems/puma-3.11.0/lib/puma/configuration.rb:243:in `app'
   /app/vendor/bundle/ruby/2.3.0/gems/puma-3.11.0/lib/puma/runner.rb:138:in `load_and_bind'
   /app/vendor/bundle/ruby/2.3.0/gems/puma-3.11.0/lib/puma/cluster.rb:397:in `run'
   /app/vendor/bundle/ruby/2.3.0/gems/puma-3.11.0/lib/puma/launcher.rb:183:in `run'
   /app/vendor/bundle/ruby/2.3.0/gems/puma-3.11.0/lib/puma/cli.rb:77:in `run'
   /app/vendor/bundle/ruby/2.3.0/gems/puma-3.11.0/bin/puma:10:in `<top (required)>'
  /app/vendor/bundle/ruby/2.3.0/bin/puma:23:in `load'
  /app/vendor/bundle/ruby/2.3.0/bin/puma:23:in `<top (required)>'
 State changed from starting to crashed
 Process exited with status 1

redis url 像往常一样在 ENV 中设置。

【问题讨论】:

  • 你是配置本地 Redis URL 还是外部服务?
  • @spickermann 你是什么意思?在 heroku 上,它应该从 REDIS_URL 配置变量中选择 URL,但由于某种原因,它现在不起作用。
  • 请您确认您在 Heroku 设置中配置了REDIS_URL,并且其值不是localhost。你的config/application.rb 中的44 行是什么样子的?
  • @spickermann REDIS_URL = redis://h:pc12cd8797ab46f3xxxx@ec2-34-227-xxx.compute-1.amazonaws.com:54419 config/application.rb 44 = Resque.workers.each { |w| w.unregister_worker}

标签: ruby-on-rails ruby heroku redis


【解决方案1】:

我终于找到了问题所在,项目配置为使用 Redis 3.3.5。他们更新了 gem,然后更改了配置。我通过在 Gemfile 中设置适用于当前配置的 gem 版本来解决它。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-09-22
    • 2015-12-09
    • 2014-07-16
    • 2015-03-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多