I really appreciate your quick reply and I have been a big fan of Sequel. I 
just want to make sure I understand correctly that I only need to call 
DB.disconnect in before_fork block and do not do anything in after_fork 
block. Will DB get the connection automatically in this case?

before_fork do |server, worker|
  # Disconnect all database connection from Sequel
  DB.disconnect
  sleep 1
end

after_fork do |server, worker|
  # Do nothing here and DB will connect automatically
end

On Monday, December 3, 2012 5:16:08 AM UTC+8, Jeremy Evans wrote:
>
> On Sunday, December 2, 2012 11:01:35 AM UTC-8, Daniel Tsai wrote:
>
>> I have the same problem and happened to google this thread. Is my modifed 
>> unicorn config ok?
>>
>> require 'sequel'
>> require 'redis'
>> require 'sidekiq'
>>
>> worker_processes 4
>> preload_app true
>> timeout 90
>>
>> before_fork do |server, worker|
>>   # Disconnect all database connection from Sequel
>>   DB.disconnect
>>   sleep 1
>> end
>>
>> after_fork do |server, worker|
>>   # Reconnect database by Sequel
>>   DB = Sequel.connect(ENV['DATABASE_URL'])
>>
>
> You don't need to manually call Sequel.connect after fork, so you should 
> remove this.  I'm not sure about Redis/Sidekiq, but the same may be true 
> for them, you should probably talk to those authors.
>  
>
>>
>>   # Reconnect Redis
>>   $redis = Redis.new(:url => ENV['REDIS_PROVIDER'])
>>
>>   # Reconnect Sidekiq Redis client
>>   Sidekiq.configure_client do |config|
>>     config.redis = { :url => ENV['REDIS_PROVIDER'], :size => 1 }
>>   end
>> end
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/sequel-talk/-/BjSibQsn6J8J.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en.

Reply via email to