* re-establish pg connection before/after fork

This commit is contained in:
Seth Call 2014-01-31 12:37:43 -06:00
parent 43d5c8465f
commit 3517cf048b
3 changed files with 11 additions and 3 deletions

View File

@ -31,6 +31,7 @@ require "jam_ruby/lib/profanity"
require "jam_ruby/lib/em_helper.rb"
require "jam_ruby/resque/audiomixer"
require "jam_ruby/resque/icecast_config_writer"
require "jam_ruby/resque/resque_hooks"
require "jam_ruby/resque/scheduled/audiomixer_retry"
require "jam_ruby/resque/scheduled/icecast_config_retry"
require "jam_ruby/resque/scheduled/icecast_source_check"

View File

@ -0,0 +1,10 @@
# https://devcenter.heroku.com/articles/forked-pg-connections
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

View File

@ -11,7 +11,6 @@ development:
host: localhost
pool: 5
timeout: 5000
prepared_statements: false
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
@ -24,7 +23,6 @@ test: &test
host: localhost
pool: 5
timeout: 5000
prepared_statements: false
production:
adapter: postgresql
@ -34,7 +32,6 @@ production:
host: localhost
pool: 5
timeout: 5000
prepared_statements: false
cucumber:
<<: *test