I have a rails web app and I´m integration a backgroud process with sidekiq. Basic integration is working fine.
The point is that I need to run the background process continuously in a loop. According to another post I have created a loop that fired the worker in an initializer. The code:
sidekiq.rb
Thread.new do
loop do
puts "Sidekiq.Initializer-->before perform worker"
MyWorker.perform_async()
puts "Sidekiq.Initializer-->after perform worker and before sleep"
sleep(1.minutes)
puts "Sidekiq.Initializer-->after sleep"
end
end
However, this initializer is running twice. First when the rails server is started up and second when the sidekiq server is started up. How can I do to have this functionality running just once.