0

Resque 1.22.0、Resque-status 0.3.3 を使用していますが、すべて正常に動作します。もしrescue-ui gemを含めると、(キューから)エラーが発生します:

failed: #<Redis::InheritedError: Tried to use a connection from a child process without reconnecting. You need to reconnect to Redis after forking.>

rake タスク コードから resque-ui を削除し、フォアグラウンドでそのままにしておくと問題なく動作します。誰もこれを修正する方法を知っていますか:非常にイライラします......

4

2 に答える 2

0

それは、しばらくの間、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クライアントかはわかりませんが、再接続が確実だったと思います暗黙的に発生する)

この助けを願っています

于 2012-10-28T16:46:55.027 に答える