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