所以我需要能够为每个 Sidekiq 线程创建一个 RabbitMQ 连接和通道,因为如果我不这样做,我会用完 RabbitMQ 连接,因为文档建议这样做。文档展示了如何使用Unicorn进行操作:
before_fork do |server, worker|
$rabbitmq_connection.close if $rabbitmq_connection
end
after_fork do |server, worker|
# the following is *required* for Rails + "preload_app true",
defined?(ActiveRecord::Base) and
ActiveRecord::Base.establish_connection
$rabbitmq_connection = Bunny.new
$rabbitmq_connection.start
$rabbitmq_channel = $rabbitmq_connection.create_channel
end
end
是否可以为 Sidekiq 线程做类似的事情?有什么我可以做的Sidekiq.server_configure
吗?看起来这是 Sidekiq 启动线程的地方,但我无论如何都看不到要挂接到启动/停止?