mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
BUGFIX: properly reconnect to the current db after forking
This commit is contained in:
@@ -238,11 +238,12 @@ module Discourse
|
|||||||
# after fork, otherwise Discourse will be
|
# after fork, otherwise Discourse will be
|
||||||
# in a bad state
|
# in a bad state
|
||||||
def self.after_fork
|
def self.after_fork
|
||||||
|
current_db = RailsMultisite::ConnectionManagement.current_db
|
||||||
|
RailsMultisite::ConnectionManagement.establish_connection(db: current_db)
|
||||||
|
MessageBus.after_fork
|
||||||
SiteSetting.after_fork
|
SiteSetting.after_fork
|
||||||
ActiveRecord::Base.establish_connection
|
|
||||||
$redis.client.reconnect
|
$redis.client.reconnect
|
||||||
Rails.cache.reconnect
|
Rails.cache.reconnect
|
||||||
MessageBus.after_fork
|
|
||||||
# /!\ HACK /!\ force sidekiq to create a new connection to redis
|
# /!\ HACK /!\ force sidekiq to create a new connection to redis
|
||||||
Sidekiq.instance_variable_set(:@redis, nil)
|
Sidekiq.instance_variable_set(:@redis, nil)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -144,6 +144,7 @@ module Export
|
|||||||
pg_dump_running = true
|
pg_dump_running = true
|
||||||
|
|
||||||
Thread.new do
|
Thread.new do
|
||||||
|
RailsMultisite::ConnectionManagement::establish_connection(db: @current_db)
|
||||||
while pg_dump_running
|
while pg_dump_running
|
||||||
message = logs.pop.strip
|
message = logs.pop.strip
|
||||||
log(message) unless message.blank?
|
log(message) unless message.blank?
|
||||||
|
|||||||
Reference in New Issue
Block a user