即是大問題之一resque一會兒看過來檢查過here
它像MySQL連接要走了問題,當一個fork
退出
它關閉所有它的連接只是在這裏的差異是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
如何這一點,你就可以解決這個
一)更新resque
也有多種方式解決(用了一段時間,但現在這個補丁更新resque)看到了here
b)若您更新用不看,那麼你可以做到這一點使用resque_hooks這樣的事情
Resque.after_fork do
Resque.redis.client.reconnect
end
c)升級Redis服務器: - 這完全確定這一點,但我注意到Redis 2.4.6 不確定該版本,儘管通過redis在內部實現了重新連接(不確定它是否是redis或redis客戶端,但可以肯定地認爲重新含蓄地發生)
希望這有助於