What is the correct way to load modules / classes from lib / when using config.threadsafe! option?

I am working to ensure that the Rails 2.3.8 application runs correctly under JRuby. Everything works fine until I turn on config.threadsafe! to achieve the concurrency that JRuby offers. This caused the modules / classes in lib / to stop loading automatically.

with config.threadsafe! included:

$ ruby script/runner -e production 'p Sim::Sim200Provisioner'

/Users/amchale/.rvm/gems/jruby-1.5.1@web-services/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:105:in `const_missing': uninitialized constant Sim::Sim200Provisioner (NameError)
    from (eval):1

with config.threadsafe! disabled people:

$ ruby script/runner -e production 'p Sim::Sim200Provisioner'
Sim::Sim200Provisioner

This file lib / sim / sim200_provisioner.rb , where Sim - application / models / sim.rb . Normally in Rails there is no problem finding and downloading a file.

Do I need to manually require all of our libraries, or is there another Rails method that I am missing?

+5
3

threadsafe! , . , , , - .

require , , initializer.

+7

config.autoload_paths config.eager_load_paths

( Rails # 6850 ! lib rails 3.2 console, lib 'config.autoload_paths' Rails 3 )

+2

, #threadsafe!

Enable stream mode. Allows simultaneous requests to the action controller and multiple connection database. It also disables the automatic loading of dependencies after loading and disables code reloading on every request, since they are mostly incompatible with thread safety.

0
source

All Articles