gpt4 book ai didi

ruby-on-rails - 为什么 Travis 在部署到 Heroku 时无法连接使用 Redis cache_store?

转载 作者:可可西里 更新时间:2023-11-01 11:21:35 24 4
gpt4 key购买 nike

我在我的 Rails 应用程序中使用 Redis 缓存:

config.cache_store = :redis_store, redis_url

当我将我的 Rails 应用程序直接推送到 Heroku 时,它已成功部署。使用 Travis 时,Heroku 部署步骤失败,因为 Assets 预编译尝试连接到 Redis。

   Running: rake assets:precompile
rake aborted!
ArgumentError: invalid uri scheme ''
/tmp/build_7c5f167bf750cb2986dbb9c3510ea11e/vendor/bundle/ruby/2.1.0/gems/redis-3.2.0/lib/redis/client.rb:390:in `_parse_options'

我尝试过各种方法:使用 rake 任务重写 RedisStore 方法,将 cache_store 实例化移动到初始化阶段,使用 Docker 代替 sudo,更改 Heroku 构建策略和其他 travis.yml 配置等。

我不想在本地预编译,也不想更改缓存解决方案。在 cedar-14 堆栈上运行的许多其他应用程序使用非常相似的设置,因此这个问题看起来有点奇怪。

有什么解决 Travis+Heroku 部署问题的建议吗?

最佳答案

在我的例子中,我通过将 redis init 更改为:

REDIS = Redis.new(:url => redis_url_string)

之前我解析 URI 并将参数传递为:

uri = URI.parse(redis_url)
REDIS = Redis.new(:host => uri.host, :port => uri.port, :password => uri.password, :scheme => uri.scheme)

我想知道cache store init是否有类似redis的init实现(我没查过那里的源)。

关于ruby-on-rails - 为什么 Travis 在部署到 Heroku 时无法连接使用 Redis cache_store?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28067644/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com