mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 09:36:19 -05:00
FIX: run reaper after fork
This commit is contained in:
parent
9a46a156e4
commit
f897c89d48
2 changed files with 17 additions and 12 deletions
|
@ -1,13 +1,2 @@
|
|||
# pg performs inconsistently with large amounts of connections
|
||||
# this helps keep connection counts in check
|
||||
Thread.new do
|
||||
while true
|
||||
sleep 30
|
||||
pools = []
|
||||
ObjectSpace.each_object(ActiveRecord::ConnectionAdapters::ConnectionPool){|pool| pools << pool}
|
||||
|
||||
pools.each do |pool|
|
||||
pool.drain(30.seconds)
|
||||
end
|
||||
end
|
||||
end
|
||||
Discourse.start_connection_reaper
|
||||
|
|
|
@ -258,9 +258,25 @@ module Discourse
|
|||
Sidekiq.redis_pool.shutdown{|c| nil}
|
||||
# re-establish
|
||||
Sidekiq.redis = sidekiq_redis_config
|
||||
start_connection_reaper
|
||||
nil
|
||||
end
|
||||
|
||||
def self.start_connection_reaper(interval=30, age=30)
|
||||
# this helps keep connection counts in check
|
||||
Thread.new do
|
||||
while true
|
||||
sleep interval
|
||||
pools = []
|
||||
ObjectSpace.each_object(ActiveRecord::ConnectionAdapters::ConnectionPool){|pool| pools << pool}
|
||||
|
||||
pools.each do |pool|
|
||||
pool.drain(age.seconds)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def self.sidekiq_redis_config
|
||||
{ url: $redis.url, namespace: 'sidekiq' }
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue