BUGFIX: Correct after_fork semantics

After fork SiteSettings was not getting a new process id,
causing site settings not to refresh properly in unicorn

This code also centralizes the logic
This commit is contained in:
Sam
2014-03-28 13:48:14 +11:00
parent 956b14a4ab
commit f3cc7360e0
8 changed files with 23 additions and 27 deletions

View File

@ -234,4 +234,17 @@ module Discourse
"/site/read-only"
end
# all forking servers must call this
# after fork, otherwise Discourse will be
# in a bad state
def self.after_fork
SiteSetting.after_fork
ActiveRecord::Base.establish_connection
$redis.client.reconnect
Rails.cache.reconnect
MessageBus.after_fork
# /!\ HACK /!\ force sidekiq to create a new connection to redis
Sidekiq.instance_variable_set(:@redis, nil)
end
end