それは、しばらくの間、resque の大きな問題の 1 つでした。こちらをご覧ください。こちらをご覧ください。
fork
終了時にmysql接続がなくなる問題のようなものです
それはすべての接続を閉じますが、ここの違いはmysql
それの代わりですredis
つまり、状況は簡単に言えばこのようなものです
#### Resque main worker
redis = Redis.new
while(true) do
#### Parent redis connection
redis.blpop(* queue_name)
#### redis queue are polled and message are consumed
#### Resque internally fork to performer the task
fork {
#### This fork used the redis connection from the main worker
#### On exit the fork close the redis connection
##### Perform the background task
}
end
## On Main Worker when the the resque try to use the same connection that was closed it raise the above error
これを解決する方法
これを解決する方法は複数あります
a) update resque (しばらく時間がかかりましたが、今はパッチが更新されています resque ) hereを参照してください
b) 見ていない更新の場合は、次のような resque_hooks を使用してこれを達成できます
Resque.after_fork do
Resque.redis.client.reconnect
end
c)Redisサーバーのアップグレード:-これは完全に確信していますが、Redis 2.4.6のバージョンがわからないことに気づきましたが、再接続は内部でredisを介して行われました(redisかredisクライアントかはわかりませんが、再接続が確実だったと思います暗黙的に発生する)
この助けを願っています