Ruby version: ruby 2.3.4p301 (2017-03-30 revision 58214) [x86_64-linux]
Sidekiq / Pro / Enterprise version(s): sidekiq-5.1.0 + sidekiq-scheduler-2.2.1
Rails version: 5.1.4
config/initializers/sidekiq.yml:Sidekiq.configure_client do |config|
require 'sidekiq-scheduler/web'
config.redis = { url: Rails.configuration.redis_url }
end
Sidekiq.configure_server do |config|
config.redis = { url: Rails.configuration.redis_url }
end
config/environments/production.rb: config.cache_classes = true
config.eager_load = true
# ...
config/application.rb: config.eager_load_paths << "#{Rails.root}/app/workers"
config.autoload_paths << "#{Rails.root}/app/workers"
# ...
config/sidekiq.yml::concurrency: 1
:schedule:
email_users:
every: 1m
class: EmailUsersWorker
app/workers/email_users_worker.rb:class EmailUsersWorker
include Sidekiq::Worker
def perform
# ...
end
end
$ bundle exec sidekiq -e production
queueing EmailUsersWorker (email_users)
enqueued retry: {"class":"EmailUsersWorker","queue":"default","args":[],"retry":true,"jid":"830039c41b88444683a7fd5d","created_at":1523192889.904502,"enqueued_at":1523192889.904532,"error_message":"uninitialized constant EmailUsersWorker","error_class":"NameError","failed_at":1523192889.9115372,"retry_count":0}
Very occasionally, the worker is invoked correctly without errors. Probably less than 1% of the time, looks like a race condition.
What I tried so far, without success:
require <rails_root>/app/workers/email_users_worker before app initialization in config/application.rbRails.logger.info("Class: #{EmailUsersWorker}") in config/application.rb logs the expected line when sidekiq is started. I.e. the constant is defined at that time.-e development (where cache_classes and eager_load are both false)Please help me resolve this issue, I would gladly cooperate with any required information.
Thank you for your cooperation. According to these docs, everything would have worked without modifying the load paths, but, sadly, it does not. Do you have any specific suggestion you could make?
Thank you in advance.
If anyone comes across this and none of the other answers on the internet help you:
sidekiq_worker_file_name.rb not SidekiqWorkerFileName.rb
Most helpful comment
If anyone comes across this and none of the other answers on the internet help you:
sidekiq_worker_file_name.rbnotSidekiqWorkerFileName.rb