DEV: Fix not being able to boot Sidekiq server in development (#16696)

This commit is contained in:
Alan Guo Xiang Tan 2022-05-11 10:38:11 +08:00 committed by GitHub
parent 907adce1cb
commit a76256756f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 14 deletions

View File

@ -27,10 +27,10 @@ if Sidekiq.server?
end
end
# defer queue should simply run in sidekiq
Scheduler::Defer.async = false
Rails.application.config.after_initialize do
# defer queue should simply run in sidekiq
Scheduler::Defer.async = false
# warm up AR
RailsMultisite::ConnectionManagement.safe_each_connection do
(ActiveRecord::Base.connection.tables - %w[schema_migrations versions]).each do |table|
@ -49,17 +49,17 @@ if Sidekiq.server?
end
end
end
end
# Sidekiq#logger= applies patches to whichever logger we pass it.
# Therefore something like Sidekiq.logger = Rails.logger will break
# all logging in the application.
#
# Instead, this patch adds a dedicated logger instance and patches
# the #add method to forward messages to Rails.logger.
Sidekiq.logger = Logger.new(nil)
Sidekiq.logger.define_singleton_method(:add) do |severity, message = nil, progname = nil, &blk|
Rails.logger.add(severity, message, progname, &blk)
else
# Sidekiq#logger= applies patches to whichever logger we pass it.
# Therefore something like Sidekiq.logger = Rails.logger will break
# all logging in the application.
#
# Instead, this patch adds a dedicated logger instance and patches
# the #add method to forward messages to Rails.logger.
Sidekiq.logger = Logger.new(nil)
Sidekiq.logger.define_singleton_method(:add) do |severity, message = nil, progname = nil, &blk|
Rails.logger.add(severity, message, progname, &blk)
end
end
Sidekiq.error_handlers.clear