summaryrefslogtreecommitdiff
path: root/config/application.rb
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2016-04-05 09:43:48 -0700
committerRémy Coutable <remy@rymai.me>2016-05-10 11:51:19 +0200
commit6da3388569b3bf31ac72663a4c13dba83d064356 (patch)
treec26b20f9b9beb2d34eaddd652313cddb8b8e832c /config/application.rb
parent3af78b5c53d5214e662aa35c6adde53d00f6c51e (diff)
downloadgitlab-ce-6da3388569b3bf31ac72663a4c13dba83d064356.tar.gz
Add eager load paths to help prevent dependency load issues with Sidekiq workers
Attempts to address #13521, #14825 Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'config/application.rb')
-rw-r--r--config/application.rb19
1 files changed, 13 insertions, 6 deletions
diff --git a/config/application.rb b/config/application.rb
index b602e2b6168..b33e57f5fcd 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -12,12 +12,19 @@ module Gitlab
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
- # Custom directories with classes and modules you want to be autoloadable.
- config.autoload_paths.push(*%W(#{config.root}/lib
- #{config.root}/app/models/hooks
- #{config.root}/app/models/concerns
- #{config.root}/app/models/project_services
- #{config.root}/app/models/members))
+ # Sidekiq uses eager loading, but directories not in the standard Rails
+ # directories must be added to the eager load paths:
+ # https://github.com/mperham/sidekiq/wiki/FAQ#why-doesnt-sidekiq-autoload-my-rails-application-code
+ # Also, there is no need to add `lib` to autoload_paths since autoloading is
+ # configured to check for eager loaded paths:
+ # https://github.com/rails/rails/blob/v4.2.6/railties/lib/rails/engine.rb#L687
+ # This is a nice reference article on autoloading/eager loading:
+ # http://blog.arkency.com/2014/11/dont-forget-about-eager-load-when-extending-autoload
+ config.eager_load_paths.push(*%W(#{config.root}/lib
+ #{config.root}/app/models/hooks
+ #{config.root}/app/models/concerns
+ #{config.root}/app/models/project_services
+ #{config.root}/app/models/members))
# Only load the plugins named here, in the order given (default is alphabetical).
# :all can be used as a placeholder for all plugins not explicitly named.