Queue Sidekiq job on Rails app start
ruby, ruby-on-rails, sidekiq
Solution
A better solution would be to create an initializer `config/initializers/sidekiq.rb`
Sidekiq.configure_client do |config|
Rails.application.config.after_initialize do
# You code goes here
end
end
Problem
I need to add a job to the Sidekiq queue when my Rails app starts, to update some data, but I don't know where is the best place to do it. Right now, I've wrote this on my `application.rb`: ``` class Application < Rails::Application config.after_initialize do MyWorker.perform_async end end ``` But the problem is that when I run the `sidekiq` command it will also load the Rails stack, so I'll end up with 2 jobs on the queue. Is there any other way of doing that? This is my first big Rails app and my first time with Sidekiq, so I don't know if I'm not understanding things correctly. That might not be the right way of doing that. Thanks!