2
我一直是这样的错误挣扎了很长一段时间:Redis的连接在多线程环境(独角兽)
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.
它间歇发生在使用独角兽和Redis的应用程序。从这redis-rb Github issue它看起来:thread_safe
选项现在默认启用。我正在使用redis 2.2.2
,因为redis 3.0.1
与最新版本的resque
不兼容。
在我的独角兽配置中,我在分叉之后使用了Redis.current.quit
。
我还使用名为ruote-redis
的gem连接到Redis,这是一个工作流引擎Ruote的存储实现。
如何确保我所有的Redis连接都稳定,并且不会再出现这个错误,这会影响我们应用的正常使用?
我没有使用线程。我很乐意使用redis-rb 3.0,但resque与它不兼容。我将'ruote-redis'宝石换成了'ruote-mon',它使用Mongo进行存储。这似乎解决了这个问题。 –