简体   繁体   中英

Rails 5.2.3: Sidekiq Scheduler gives NameError: uninitialized constant in Production

In my Rails 5.2.3 app I have config/sidekiq.yml which looks like this:

:verbose: true
:concurrency: 30
:queues:
  - [mailers, 7]
  - [critical, 6]
  - [default, 5]
  - [low, 4]

:logfile: ./log/sidekiq.log

:schedule:
  ScheduledNotices:
    queue: low
    cron: '0 0 * * * *' # every hour

My ScheduledNotices is placed in lib\\scheduled_notices.rb

At the moment in development environment Scheduler works as expected, however in production I get this error: NameError: uninitialized constant ScheduledNotices

In my application.rb I have:

config.autoload_paths += %W(#{config.root}/lib)

What am I doing wrong, please?

It can be realated to path autoload issue, check this for more details: https://github.com/rails/rails/issues/13142#issuecomment-275492070

What you should do is to change:

config.autoload_paths += %W(#{config.root}/lib)

to

config.eager_load_paths << Rails.root.join('lib')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM