Postgres error on Heroku with Resque

冷暖自知 提交于 2019-11-28 21:28:24

Thanks to the comments of "Rails beginner" and "mu is too short" I found the solution.

I've added this to an initializer and it did the trick!

Resque.after_fork = Proc.new { ActiveRecord::Base.establish_connection }

I had the same issue, but to solve it my app actually required a before_fork and not an after_fork. Hope this helps someone.

Resque.before_fork = Proc.new { ActiveRecord::Base.establish_connection }

This article from heroku explains how to properly connect and disconnect connections for resque:

Resque.before_fork do
  defined?(ActiveRecord::Base) and
    ActiveRecord::Base.connection.disconnect!
end

Resque.after_fork do
  defined?(ActiveRecord::Base) and
    ActiveRecord::Base.establish_connection
end
Rob
Resque.before_fork = Proc.new { 
     ActiveRecord::ActiveRecord::Base.verify_active_connections!
} 

would be even nicer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!