sidekiq 线程的单例可能吗?

Singleton for sidekiq threads possible?

所以我需要能够为每个 Sidekiq 线程创建一个 RabbitMQ 连接和通道,因为如果我不这样做,我会 运行 脱离 RabbitMQ 连接,并且因为 docs suggest it. The docs show how to do it with 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 有什么我可以做的吗?看起来 this 是 Sidekiq 启动线程的地方,但无论如何我看不到挂接到 start/stop?

创建您自己的 RabbitMQ 连接池,详见此处:

https://github.com/mperham/sidekiq/wiki/Advanced-Options#connection-pooling