Reputation: 19150
I'm using Rails 5.0.1 on mac OS X. I just installed redis via homebrew, and have this in my Gemfile
gem 'sidekiq'
and I have this file, app/workers/run_crawlers_worker.rb, ...
class MyWorker
include Sidekiq::Worker
def perform()
puts "about to fire up service ..."
svc = MyService.new
svc.do_tasks
puts "done invoking call"
end
end
At a place in my web application, I have
MyWorker.perform_async()
although I'm confident the above is getting called, I don't see any of my "perform" method in my worker called (I don't see any of hte puts output and I don't see the results of the "do_tasks" method getting executed in my db). Is there something additioanl I need to configure to get my method invoked?
Upvotes: 2
Views: 1227
Reputation: 8122
Is there something additioanl I need to configure to get my method invoked?
You need sidekiq process running in background which will be responsible to run the jobs you enqueue.
Is there any way to get "bundle exec sidekiq" to automatically run when I fire up my Rails server?
Put into foreman. It is pretty easy. I am assuming basic configuration, this is all you need to do
foreman
gem. (put into bundle and do bundle install)Procfile
in rails root. Assuming basic configuration, this is what Procfile
suppose to contain
web: bundle exec rails server
worker: bundle exec sidekiq
then to execute both command spontaneously, just execute foreman start
Upvotes: 0