Created
August 14, 2015 13:56
-
-
Save reidmorrison/5e932a84d04f214ac5a2 to your computer and use it in GitHub Desktop.
JRuby startup under load causes invalid LoadError - no such file to load
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Fixes "LoadError" "no such file to load" on JRuby 1.7 | |
# Place at the top of application.rb | |
# Override Kernel#autoload and Module#autoload to #require when Web Server or Worker | |
# so that classes are all loaded in highly concurrent environments | |
# Also forces the code to be loaded up front instead of on demand in production | |
begin | |
# Since Rails has not yet been loaded we have to use the env vars | |
rails_env = ENV["RAILS_ENV"] || ENV["RACK_ENV"] || "development" | |
if (['production', 'release', 'hotfix'].include?(rails_env)) | |
def Kernel | |
def autoload(module_, filename) | |
require filename | |
end | |
end | |
def Module | |
def autoload(module_, filename) | |
require filename | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment