【发布时间】:2012-06-07 04:53:39
【问题描述】:
我已经为这个错误苦苦挣扎了很长一段时间:
Redis::ProtocolError: Got 'i' as initial reply byte.
If you're running in a multi-threaded environment, make sure you pass the :thread_safe
option when initializing the connection. If you're in a forking environment, such as
Unicorn, you need to connect to Redis after forking.
在使用 Unicorn 和 Redis 的应用程序中会间歇性发生这种情况。从这个redis-rb Github issue 看来,:thread_safe 选项现在默认启用。我正在使用redis 2.2.2,因为redis 3.0.1 与最新版本的resque 不兼容。
在我的 Unicorn 配置中,我在分叉后使用 Redis.current.quit。
我还使用名为 ruote-redis 的 gem 连接到 Redis,它是工作流引擎 Ruote 的存储实现。
我如何确保我的所有 Redis 连接都稳定,并且我不会再收到这个影响我们应用程序正常使用的错误?
【问题讨论】:
标签: ruby-on-rails ruby redis unicorn