backburner
backburner copied to clipboard
How to recover DB connection between two jobs in production ?
Using backburner with ThreadsOnFork
in production with Rails 4.2 and postgresql.
If I stop and restart the postgresql service on my Linux box, Rails can reconnect to the new postgresql service but the workers can't access to the new instance of the database.
I'm getting a PG::UnableToSend: no connection to the server
error when the postgresql service is stopped and after it's restarted.
Some people had the same kind of problem with other queueing systems, and they recommend to run something like this
Resque.after_fork = Proc.new { ActiveRecord::Base.establish_connection }
How can I achieve this with Backburner ?
Should I put this in config.on_error
?
+1
I've actually been working on this the past couple days (it's coming as a side effect of handling dead connections to beanstalk).
The first revision will use the existing hook system so you'll likely need to either reopen the world class that you're using or subclass and extend.
has the hook system available on latest version?