Reputation: 1399
I'm using Rails 4.1.5 and Sidekiq 3.3.0. I have set the recurrence of this worker to execute after every one minute. It works fine on local but throwing an error on production and staging environments. Although the worker is doing its job and saving records only throwing errors after one minute.
2016-01-21T10:50:00.594Z 5173 TID-osv5dzz5o WARN: uninitialized constant ViewDBWorker
app/workers/view_db_worker.rb:
class ViewDBWorker
include Sidekiq::Worker
include Sidetiq::Schedulable
recurrence { hourly.minute_of_hour((0..59).to_a) } if Rails.env.staging? || Rails.env.production?
def perform
begin
do_process()
rescue => e
puts "Error message: #{e.message}"
end
end
def do_process()
puts 'The worker !!'
end
end
application.rb
config.eager_load_paths += %W(#{config.root}/app/workers)
Upvotes: 2
Views: 981
Reputation: 652
You don't need to add directories to load paths in application.rb
if you defined you worker classes in app/*
folder of rails. Rails will automatically load those file.
If you have defined your classes somewhere else e.g. in the lib/worker/*
folder then you need to add this into your application.rb
config.autoload_paths += %W(#{config.root}/lib/workers)
config.eager_load_paths += %W(#{config.root}/lib/workers)
Along with this your issue might be running processes of sidekiq. You can see your sidekiq processes(ps aux | grep sidekiq
) and kill those. Then restart the worker.
Reference: https://github.com/mperham/sidekiq/issues/1958
Check the answer of @pkoltermann on this issue
Upvotes: 4